• Resolved mrtoner

    (@mrtoner)


    Before I get in over my head, could someone point me in the right direction? When viewing a single post in category A, I want another post from category B inserted at the end. The category B post will be the most recent of all the category B posts and will be only an excerpt of that post, with a “read more” link to the full post.

    TIA!

Viewing 2 replies - 1 through 2 (of 2 total)
  • So do a get_posts loop in your single.php after the loop that displays the single post.

    One example to consider:
    https://www.daobydesign.com/blog/2007/07/modifying-wordpress-front-page/

    Thread Starter mrtoner

    (@mrtoner)

    Thanks, Michael, it wasn’t so hard after all:

    <?php
    if (in_category(array('resources','news'))) :
      $postslist = get_posts('category_name=recommends&numberposts=1&order=DESC&orderby=date');
      foreach ($postslist as $post) :
        setup_postdata($post);
      ?>
    <div>
    <br /><br />
    <h4>Not free, but worth it...</h4>
    <?php the_excerpt(); ?> <a href="<?php the_permalink(); ?>">Read more ?</a>
    </div>
    <?php endforeach; ?>
    <?php endif; ?>
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Insert post within another’ is closed to new replies.