• Resolved sBowers

    (@sbowers)


    I am trying to use a single page template for multiple post feeds. I have a if statement the grabs the posts:

    <?php
    // page id 21 will get category ID 12 posts, page 16 will get category 32 posts, page 28 will get category 17 posts
    if (is_page('28') ) {
    $cat = array(5);
    } elseif ( is_page('21') ) {
    $cat = array(6);
    } elseif ( is_page('32') ) {
    $cat = array(7);
    } else {
    $cat = '';
    }
    
    $showposts = -1; // -1 shows all posts
    $do_not_show_stickies = 1; // 0 to show stickies
    $args=array(
       'category__in' => $cat,
       'showposts' => $showposts,
       'caller_get_posts' => $do_not_show_stickies
       );
    $my_query = new WP_Query($args); 
    
    ?>

    Based on the page it grabs the correct posts but to make the strategy work I need to be able to also include the_content from the respective page eg

    If it is the Advisers page the_content has some happy text about Advisers and if it is the Regulators page it has the_content happy text about the Regulators.

    I have been able to grab the_title of the page but I am not sure how to display both the posts in the category and the content of the page that is calling the function.

    Any assistance is appreciated.

Viewing 2 replies - 1 through 2 (of 2 total)
  • add a normal loop before your code:

    <?php  while (have_posts()) :
          the_post();
          the_content();// and whatever you want to show from the original page content
       endwhile; ?>
    Thread Starter sBowers

    (@sbowers)

    Most excellent. Thank you.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘the_content, plus posts?’ is closed to new replies.