I have tried this code:
<?php query_posts(array( 'meta_key' => 'custom_cat', 'meta_value' => 'creative', 'post_type' => 'page' )); echo '<ul id="creative_services" class="clearfix row">'; if ( have_posts() ) while ( have_posts() ) : the_post(); echo '<li class="col-md-3">'; echo '<a class="popover-dismiss" data-toggle="popover" title="'; echo $post->post_title; echo '" data-placement="bottom" data-content="'; echo $post->post_content; echo '"><i class="'; get_post_meta( get_the_ID(), 'fa_icon' ); echo '"></i></a>'; echo '<h3>'; the_title(); echo '</h3>'; endwhile; echo '</ul>'; wp_reset_query(); ?>
to display the custom field value as a class name, but the value is not displaying. Please help me find the problem or solution to display the custom field value as class name. I'm having hard time to debug this codes because i'm not a programmer, i'm a designer, still in the process of exploring wordpress.
Try adding echo
before get_post_meta( get_the_ID(), 'fa_icon' );
so it would be:
<?php
query_posts(array(
'meta_key' => 'custom_cat',
'meta_value' => 'creative',
'post_type' => 'page'
));
echo '<ul id="creative_services" class="clearfix row">';
if ( have_posts() ) while ( have_posts() ) : the_post();
echo '<li class="col-md-3">';
echo '<a class="popover-dismiss" data-toggle="popover" title="';
echo $post->post_title;
echo '" data-placement="bottom" data-content="';
echo $post->post_content;
echo '"><i class="';
echo get_post_meta( get_the_ID(), 'fa_icon' );
echo '"></i></a>';
echo '<h3>';
the_title();
echo '</h3>';
endwhile;
echo '</ul>';
wp_reset_query(); ?>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.