• Resolved threesongbirds

    (@threesongbirds)


    I apologize in advance as I feel this will turn into “find what’s wrong with the code.”

    I am currently using the AutoFocus theme, and I like how the category archive is laid out so I try trying to create a page to follow the same layout as I didn’t want to create a static page. (I realize now that it may have been easier to just change the menu, but I think I’m… 1/3 of the way there?)
    Either way, I ended up trying to create a template by taking the code in the category.php and adding it in between the div contents, switching get_excerpt with get_content, and adding <?php query_posts(“cat=#”); ?> near the beginning (which probably is the wrong way to go about this).

    Category.php: http://threesongbirds.coloursplash.org/?cat=6
    Page: http://threesongbirds.coloursplash.org/?page_id=323
    The navigation does not work in addition to the obvious differences.

    If there is an easier way, a plug-in, or people who are willing to help, I will be very grateful.

    Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter threesongbirds

    (@threesongbirds)

    Sorry, don’t mean to bump… just completely forgot to add the code…

    http://pastebin.com/BgUyNHhc

    Try!

    <?php
    $args = array(
       'posts_per_page' => 10,
       'cat' => 5,
       'paged' => $paged
    );
    ?>
    <?php query_posts( $args ); ?>

    No Pagination to get all posts in the category change 10 to:

    'posts_per_page' => -1,

    HTH

    David

    Thread Starter threesongbirds

    (@threesongbirds)

    Sorry, I’m not as familiar with the wordpress tags. What does the that code do? I’m guessing it replaces the <?php query_posts(“cat=#”); ?> in the templete ?

    Thanks again..

    Hi,
    I see you have it sorted.

    What does the that code do?

    What you was missing was the navigation, all we done was told WordPress we wanted the query results to be paged, using the WordPress global $paged.

    'paged' => $paged

    The other line just tells WordPress how many posts to show, the default (10) is set in settings, but we could over-write that and display more or less, if we have large posts we may only want two so the visitor does not have to scroll.

    So we would add:

    'posts_per_page' => 2,

    Guessing it replaces the <?php query_posts(“cat=#”); ?> in the templete?

    That is correct, all we have done is created an argument array and passed it to query_posts( $args ), it is a matter of choice, I just thing the array is easier to read, construct and understand, than a long text string.

    As we can see it can get messy, although for this example below we should use wp_query();

    <?php query_posts( 'cat=5&posts_per_page=10&paged=$paged&order=ASC&orderby=title' ); ?>

    If your topic is resolved can you change the status of the topic please.

    HTH

    David

    Thread Starter threesongbirds

    (@threesongbirds)

    Thank you so much for the explanation 🙂

    However, I still have some fixes to do/parts I don’t understand so I’m going leave this open until I figure it out.

    Thanks again!

    Thread Starter threesongbirds

    (@threesongbirds)

    Nevermind, found a plug-in that will do what I want it to do.

    Thanks for you your help, David/Digital Raindrops.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Creating a page that looks like category.php (Template)’ is closed to new replies.