how to display meta field
-
I am using this plugin and everything seems to work fine, but I am not able to display my custom meta box field for some reason. Can anyone take a look at my code incase I am overlooking at it?
Thanks[code]
<?php
function scpt_cms() {
if ( ! class_exists( 'Super_Custom_Post_Type' ) )
return;
// Create custom post types Services
$services = new Super_Custom_Post_Type( 'services' );
$services->set_icon( 'cogwheels' );
$services->add_meta_box( array(
'id' => 'basic-information',
'context' => 'side',
'fields' => array(
'cost' => array(),
'category' => array( 'type' => 'radio', 'options' => array( 'All', 'WordPress', 'Drupal', 'Joomla!', 'Zen Cart', 'Magento' ) ),
)
) );$orders = new Super_Custom_Post_Type( 'order' );
}
add_action( 'after_setup_theme', 'scpt_cms' );[/code]
and I display the cpt with the following
[code]
$args = array( 'post_type' => array('services'),
'posts_per_page' => -1 );
$loop = new WP_Query( $args );
if ( have_posts() ) :
$count = 0;/* Start the Loop */
while ( $loop->have_posts() ) : $loop->the_post();
$count++;
if ($count <= 1) :
/* Include the post format-specific template for the content. If you want to
* this in a child theme then include a file called called content-___.php
* (where ___ is the post format) and that will be used instead.
*/ ?>
<div class="service">
<header class="entry-header">
<?php the_post_thumbnail(); ?>
<h2 class="entry-title"> " title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark">
<?php if ( get_post_meta( $post->ID, 'category', true ) ) : ?>
<?php echo get_post_meta( get_the_ID(), 'ccategory', true ) ?>
<?php endif; ?>
<?php echo get_post_meta($post->ID, "category", true); ?>
<?php the_title(); ?>
</h2>
</header>
<!-- .entry-header -->
</div>
<!-- #post -->
<?php endif;
endwhile;
endif; ?>
[/code]
everything works, but doesn’t display the meta keys. everything is OK from the dashboard.
Help please need this urgently.
- The topic ‘how to display meta field’ is closed to new replies.