Support » Fixing WordPress » Side-by-side columns, different categories?

  • Resolved yosemite


    Tried wp-hackers, no response there, so:

    Trying to develop a theme (at that has 2 columns and a sidebar. I’m trying to use the query_posts (running 2 separate loops in index.php) and have success with hard-coding e.g.; query_posts(‘cat=2,-11&showposts=10’); in each separate loop, but when I try to make use of Ozh’s Theme Tool Kit to allow users control of which categories are displayed in the columns it breaks. Whether I build a function and use it:
    $cats2=corporate_slave_col2cats() . corporate_slave_postquant();
    query_posts($cats2); echo $cats2;

    or I use variables:
    global $corporate_slave; $cats2=
    "'".$corporate_slave->option['col2cats']. '&showposts='.
    $corporate_slave->option['postquant']. "'"; query_posts($cats2); echo $cats2;

    I end up with the correct string echoed from $cats2, but it just displays all categories.

    Any suggestions, ideas?

Viewing 7 replies - 1 through 7 (of 7 total)
  • That was the basis for my setup. And it works quite well (when I enter the arguments for query_posts() manually), but I added an entry in Theme Options so the owner/user could enter which categories go in which column.

    As soon as I apply those as variables/functions with query_posts() it seems to break.

    (As we discussed in IM, I suspect it has to do with me not passing ‘real’ strings? Still researching.)

    An example: If I use query_posts('cat=3&showposts=10') it works fine.

    If I use:
    query_posts($cats2); (note that echo $cats2; returns 'cat=3&showposts=10') it breaks and just displays all posts/categories.

    What happens if you don’t use the ‘ on both ends of the $cats2 variable?

    Tried a number of variations (this time echo $cats2; returns cat=3, but with or without single-ticks it behaves the same (ignores category selection/argument).

    I’m sure you’ve seen this but I’ll point it out just in case:

    Thanks MichaelH, you were right, I just had some mental block thing going.

    I have been referring to that page extensively, but I was also handling parsing the string in the /[themename]/functions.php file (using Ozh’s Theme Toolkit) at some point and borked it up apparently. Once I gave up on any formatting for the ticks (or cat=)in the /[themename]/functions.php and just followed your link example, it worked. Imagine that. *blushes*

    Thanks again ;’)

    Working code:
    <?php $cat_id='cat=' . $corporate_slave->option['col1cats']; ?>
    <?php query_posts($cat_id); ?>

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Side-by-side columns, different categories?’ is closed to new replies.