0

I have created a custom post type ui with custom field.

Here is my code:

<?php
/*
Template Name: Diseases & Conditions
*/
?>

<?php get_header(); ?>


<div class="section inner-cont">
  <div class="container">
    <div class="row">
      
      <?php if (have_posts()) : ?>
        <?php while (have_posts()) : the_post(); ?>

          <div class="col-sm-12">
            <div class="main-title">
              <h1><?php the_title(); ?></h1>
            </div>
            <div class="card-text">
        <?php endwhile; ?>
      <?php endif; wp_reset_postdata(); ?>
      
          <?php $mydiseases = new WP_Query(array(
            'post_type' => 'diseases_condition' 
          )); ?>
          
          <?php while( $mydiseases -> have_post() ) : $mydiseases -> the_post(); ?>

            <div class="row">
              <div class="col-sm-12">
                
                <?php the_title(); ?>
                
                <?php the_post_thumbnail();?>
                
                <div class="card-text">
                  <?php the_excerpt(); ?> 
                </div>
                <div class="card-btn">
                  <a href="<?php the_permalink() ?>" class="btn btn-primary">read more</a>
                </div>
                
              </div>
            </div>

          <?php endwhile; ?>
          
        </div>
      </div>
      
    </div>
  </div>
</div>

<?php get_footer(); ?>

But my page is not showing custom post-type details, as like thumbnail, excerpt, Title etc...

Here is Screenshot enter image description here

I want to add those into a new page. How can I do this?

  • Do you have debugging enabled? have_post() is not a function, it's have_posts(). – Milo Dec 30 '17 at 15:43
  • Thank you. It is solve. But I cannot show excerpt or cannot fetch value from custom field. How can I do this? – Pixelnav Admin Dec 30 '17 at 19:20
1

Have you linked the acf-fields to the post-types? then just call echo get_field('your_field_name_here') ; from inside the loop. or echo get_field('your_field_name_here', 'id_or_something') ; from outside the loop.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.