WordPress.org

Support

Support » Themes and Templates » [Resolved] Post display according to page

[Resolved] Post display according to page

  • 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.

Viewing 1 replies (of 1 total)
  • 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.

Viewing 1 replies (of 1 total)
  • The topic ‘[Resolved] Post display according to page’ is closed to new replies.
Skip to toolbar