WordPress.org

Ready to get started?Download WordPress

Forums

Paged Query (4 posts)

  1. tsquez
    Member
    Posted 3 years ago #

    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

  2. stvwlf
    Member
    Posted 3 years ago #

    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.

  3. tsquez
    Member
    Posted 3 years ago #

    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.

  4. Mark / t31os
    Moderator
    Posted 3 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.