Viewing 7 replies - 1 through 7 (of 7 total)
  • yes

    to display one category of posts on a page:
    edit the page.php template in a text editor – not a word processor
    /wp-content/themes/{themename}/page.php

    find the start of the WordPress loop
    ( looks something like this- sometimes on one line)

    <?php if (have_posts()) : ?>
       <?php while (have_posts()) : the_post(); ?>

    add this code before those lines – change the category ID of 12 to whatever category ID you want displayed on this page.

    <?php
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    query_posts("cat=12&amp;paged=$paged");
    } ?>

    You also need to exclude that same category from appearing on your regular posts page.

    Before the WordPress loop in theme file index.php add this line of code

    <?php if (is_front_page()) {
      query_posts("cat=-12");
    ?>

    If there already is a query_posts statement on your index.php page, instead of adding those lines, add this &amp;cat=-12 within the parentheses instead of adding another query_posts line – example query_posts("showposts=5&amp;cat=-12");

    Thread Starter LaneLester

    (@lanelester)

    Thanks a bunch! I’m looking forward to giving it a shot.

    Lane

    Thread Starter LaneLester

    (@lanelester)

    I’m back! With the above change, index.php generated this error:
    Parse error: syntax error, unexpected $end in /home/crsblog/public_html/wp-content/themes/CRS/index.php on line 42

    I see there’s an open brace and no close brace; is that it?

    I don’t know PHP, although I’m not afraid to mess it up.

    Lane

    Thread Starter LaneLester

    (@lanelester)

    I just set up a new page to receive the special posts, and it generated a similar error:
    Parse error: syntax error, unexpected ‘}’ in /home/crsblog/public_html/wp-content/themes/CRS/page.php on line 10

    Lane

    Hi

    yes, sorry should be this
    `<?php if (is_front_page()) {
    query_posts(“cat=-12”);
    } ?>

    that is

    <?php if (is_front_page()) {
    query_posts("cat=-12");
    } ?>

    Thread Starter LaneLester

    (@lanelester)

    I used the close brace I took out of the first snippet. [grin]

    Now the changes work perfectly and the special category appears only on the designated page.

    Thank you very much for your help.

    Lane

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Possible to Have Some Category Posts with Different URL from Others?’ is closed to new replies.