0
votes

I created post template for a specific category, where are thumbnail, title, excerpt and I added additional div to the template with custom content, which will be generated automatically, let it be div class = "custom". I also created a loop on the blog page which shows all post from this specific category. I know how to show thumbnail, title, excerpt, but don't know how to show .custom. How should I create this loop? Thank you

<?php
        if ( have_posts() ) :
          query_posts('cat=1');   
          while (have_posts()) : the_post();  
        ?>
        <div class = "programs-flex-item">
          <div class = "programs-flex-item__title"><?php the_title(); ?></div>
          <div class = "programs-flex-item__image"><?php the_post_thumbnail(); ?></div>
          <div class = "programs-flex-item__excerpt"><?php the_excerpt(); ?></div>
          <div class = "custom">HERE IS CUSTOM CONTENT!!!</div>

        </div>
         <?php 
          endwhile; 
          endif;
        wp_reset_query();                
      ?>
1
what do you mean by CUSTOM CONTENT here? what you want to add as CUSTOM CONTENT there exactly? - Anant Kumar Singh
@AlivetoDie it will be random html content generated with js on post template (single.php for example) - Yaroslav Saenko

1 Answers

0
votes

Best way to store custom post values are metadata or post meta. It's a basic key, value pair which can be expanded by using custom post fields plugins (choose any you like). In code you can use

get_post_meta();

to get the metas for a post. Link here. Also check this answer for more information