Support » Plugins and Hacks » Hacks » Paged Query

  • I need a little help from any of the gurus out there. I have a custom query:

    $todaysDate = date('m/d/Y H:i:s'); 
    
    query_posts('category_name=events&meta_key=Date&meta_compare=>=&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC');
    
    if (have_posts()) : while (have_posts()) : the_post(); ?>

    but I need to add the the paged code to it:

    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;

    and everything I have tried doesn’t seem to work. Anyone have any ideas? Any help is greatly appreciated

Viewing 3 replies - 1 through 3 (of 3 total)
  • Without reviewing if your query posts statement is correct (just put the paging code in the correct place)

    $todaysDate = date('m/d/Y H:i:s'); 
    
    $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
    
    query_posts("paged=$paged&". 'category_name=events&meta_key=Date&meta_compare=>=&meta_value=' . $todaysDate . '&orderby=meta_value&order=ASC');
    
    if (have_posts()) : while (have_posts()) : the_post(); ?>

    The double quotes I added are necessary.

    hey thank a lot amigo, that worked like a charm. I never thought of putting the paged in right before the category name.

    None the less it worked.

    It’s not the placement that was the issue, variables aren’t interpreted in a single quoted string, where as they are inside a double quoted string..

    'paged=$paged'

    In this instance the variable is treated literally as the text $paged, ie. the word paged preceded by a dollar character.

    "paged=$paged"

    PHP interprets the variable and in turn passes along the variable’s value, ie. it’s no longer treated literally.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Paged Query’ is closed to new replies.