• Ben B

    (@ben-b)


    Hi All

    I’m using twentyeleven as a theme and am modifying the “featured slider”. I write plenty of pages as well as posts and would like a query to return:
    – ‘Sticky’ Posts — the default functionality; AND
    – Pages that have a custom value set to 1

    I have been through the codex and arrived at the query below. While each of the nested arrays works alone, when I use the ‘relation’ operator it seems to return all posts.

    Can anyone help me get the syntax right as I know the queries are solid.

    Thanks

    Ben

    $featured_args = array(
    'featured_query' => array(
    'relation' => 'OR',
    array(
    'post_type' => 'page',
    'post_status' => 'publish',
    'meta_key' => 'featured-page', 'meta_value' => '1'
    ),
    array(
    'post__in' => $sticky,
    'post_status' => 'publish',
    'posts_per_page' => 10,
    'no_found_rows' => true
    )
    )
    );

Viewing 2 replies - 1 through 2 (of 2 total)
  • esmi

    (@esmi)

    Do not edit the Twenty Eleven theme. It is the default WordPress 3.2 theme and having access to an unedited version of the theme is vital when dealing with a range of site issues. Create a child theme for your changes. Once your child theme is active, we should be able to help with the customisation.

    Thread Starter Ben B

    (@ben-b)

    Yes, sorry, I should have said I am working on a child of twentyeleven…I know that’s the best way to tackle it.

    I’m editing content-featured.php in the child theme.

    Regards

    Ben

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Query to Return Pages AND Posts’ is closed to new replies.