WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Post display according to page (2 posts)

  1. rocketboy07
    Member
    Posted 1 year ago #

    Ok I have been working on this all day and am haven't gotten any where. I am trying to make a single template to display posts according to the page you are on. I know to use query_posts() but I seem to have problems with my php switch case.

    <?php
    $currenttitle=the_title_attribute("","",FALSE);
    switch($currenttitle):
    case "Private: A test":
    $mycat=5;
    break;
    endswitch;
    $args='cat='.$mycat.'&showposts=1';
    query_posts($args);
    if ( have_posts() ) while ( have_posts() ) : the_post(); ?>

    I got the title by doing an echo of $currenttitle and copy and pasted it in and it doesn't want to work. If I manually set $currenttitle to "Private: A test" it works so what am I doing wrong? I have also used wp_title and took a substring from it and that didn't work either. I would appreciate any help or suggestions.

  2. rocketboy07
    Member
    Posted 1 year ago #

    So after a little more looking I managed to find a solution. Using is_page() in an if statement works but if you know a better solution please feel free to put it here for others to use.

Topic Closed

This topic has been closed to new replies.

About this Topic