WordPress.org

Forums

Query to Return Pages AND Posts (3 posts)

  1. Ben B
    Member
    Posted 3 years ago #

    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
    )
    )
    );

  2. esmi
    Forum Moderator
    Posted 3 years ago #

    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.

  3. Ben B
    Member
    Posted 3 years ago #

    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

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.