WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] some1 help with my syntax? $posts= (4 posts)

  1. Cathy Tibbles
    Member
    Posted 6 years ago #

    This is the first string I've needed in my category template - i want to alphabetize posts IF in category 7 or 3. This (my guess) is obviously not viable! Can anyone help me with this?

    <?php
    if (is_category('7'))
    {   $posts = query_posts($query_string .
        '&orderby=title&order=asc&posts_per_page=10')
    }   else
        if(is_category('3'))
        $posts = query_posts($query_string .
        '&orderby=title&order=asc&posts_per_page=10');
        if (have_posts()) : while (have_posts()) : the_post(); ?>
  2. moshu
    Member
    Posted 6 years ago #

    Probably a missing { after else... then somewhere closing it...

    But why don't you just make a category-7.php and a category-3.php template file - so you don't have to struggle with conditionals?

  3. Cathy Tibbles
    Member
    Posted 6 years ago #

    ummmmm, cause I didn't think of it! I will do exactly that. I know your approach is to stay away from coding, I just have a hard time seeing the wordpress logic. Whereas, computer logic is intuitive, and it's a matter of syntax. (which I guess is quite a BIG matter!)

    :) thanks a ton, I'm going to make category templates now. :)

  4. moshu
    Member
    Posted 6 years ago #

    When it comes about template... the "logic" is outlined here:
    Template_Hierarchy.

Topic Closed

This topic has been closed to new replies.

About this Topic