• I made a theme option to choose from which category to display posts on the homepage. The code is..

    <?php query_posts('cat=$theme_category&showposts=$theme_posts_number'); ?>
    		<?php while (have_posts()) : the_post(); ?>
    		<?php the_post_thumbnail( 'frontpage' ); ?>
    <?php endwhile ?>

    I would think that $theme_category will call the number I put in the option but it doesn’t. I’m not sure what I’m doing wrong here..

Viewing 8 replies - 1 through 8 (of 8 total)
  • Thread Starter nemci7v

    (@nemci7v)

    update:

    I tried <?php echo $theme_category;?>

    but it retrieves all the posts from every category instead the one I put in options. hmm..

    Where are you calling this theme option from the database?

    Thread Starter nemci7v

    (@nemci7v)

    From the functions.php using the

    $themename = "Theme Name";
    $shortname = "theme";
    $options = array (
    ...

    technique

    Is this a theme option as in the user can enter a category name or id and have that option saved? Or are you just setting up a variable in functions.php? If it’s the latter, why not just add it to the template?

    Use double quotes in your query posts line and the variables will work..

    Oh well spotted! (new cat?)

    <?php query_posts('cat=' . $theme_category . '&showposts=' . $theme_posts_number); ?>

    should work too.

    Figured the double quotes would be easier … less to explain …

    Same cat, different pic.. ??

    Thread Starter nemci7v

    (@nemci7v)

    Thank you!! Both solutions worked ??

    Nice new cat pic ??

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Query posts using category option’ is closed to new replies.