• Hi, I’m a CPT newbie.

    I’ve made a custom post type named “event” in CPT UI and added some fields to it using custom fields.
    Then I’ve created a page named “single-event.php” in my theme’s folder and added the following code, but nothing is being displayed and also I can’t see any errors in my logs.

    What I’m doing wrong?

    (Fields ‘event_name’ and ‘start_date’ are my generated fields using custom fields)

    <?php
    /**
    * Template Name:events
    *
    * @package sparkling
    */

    get_header(); ?>

    <div id=”primary” class=”content-area”>

    <main id=”main” class=”site-main” role=”main”>

    <?php
    $args = array( ‘post_type’ => ‘events’, ‘posts_per_page’ => 10 );
    $loop = new WP_Query( $args );
    while ( $loop->have_posts() ) : $loop->the_post();
    the_title();
    echo ‘<div class=”entry-content”>’;
    the_field(‘event_name’);
    the_field(‘start_date’);
    echo ‘</div>’;
    endwhile;

    ?>

    </main><!– #main –>
    </div><!– #primary –>

    <?php get_sidebar(); ?>
    <?php get_footer(); ?>

    Thanks,
    Kasra

Viewing 2 replies - 1 through 2 (of 2 total)
  • Hi,

    This forum is for general WP questions and issues.

    You havent explained what you are using to create fields, but based on your code, it seems to be the ACF plugin.

    Please post your issue in the ACF forums or whichever plugin you are using.

    Thread Starter kyousefi

    (@kyousefi)

    Hi, Ok Thanks.
    /K

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Can't display custom fields in my custom post type page’ is closed to new replies.