Wordpress Custom Fields for Custom Post Types

后端 未结 2 640
谎友^
谎友^ 2021-01-29 04:24

This issue has arisen for several people in the past but the solutions for their issues have not worked for me and I have tried alot!

In Wordpress I have created 3 cust

相关标签:
2条回答
  • 2021-01-29 04:36

    Output the custom field data from ACF with.

    the_field('the-field-name');
    

    get_field('the-field-name') is used for conditionals ex if (get_field('my-field'): etc. You can also print the contents using

    echo get_field('the-field-name');
    

    I would say that your issue with Vimeo shortcodes and Custom Fields might be related to the plugin wasent built to run thru custom fields. It might be that it only checks thru the_contents() for the shortcode.

    0 讨论(0)
  • 2021-01-29 04:50

    To display the value of custom fields in your loop you can use this snippet of code:

    <?php query_posts( 'post_type=music'); ?>
      <?php while ( have_posts() ) : the_post(); ?>
       <?php get_template_part( 'content',  get_post_format() ); ?>
    
       <?php $what_name_you_want=get_post_meta($post->ID,'Your Custom Field Name',true); ?>
    
        <?php echo $what_name_you_want; ?>// This call the value of custom field
    
    
                    <?php comments_template( '', true ); ?>
                <?php endwhile; // end of the loop. ?>
    

    Tell me if it works!

    0 讨论(0)
提交回复
热议问题