Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3315466
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T22:21:13+00:00 2026-05-17T22:21:13+00:00

I’ve got a template that I’m using that has the option of showing either

  • 0

I’ve got a template that I’m using that has the option of showing either a set of posts on the front page in a featured section or, optionally, display a set of specified pages in the same featured area. I found the code where it displays either/or, however I’m not exactly sure how to combine the two together and get a list of a set of posts AND pages together.

It’s my understanding that query_posts() overrides whatever set of items WordPress displays on the page, so here, depending on what mode the theme is in, it passes in parameters to query_posts() to grab posts of a particular category, or passes in an array of pages:

<div id="slides">
    <?php global $ids;
    $ids = array(); 

    $featured_cat = get_option('mytemplate_feat_cat'); 
    $featured_num = get_option('mytemplate_featured_num'); 

    if (get_option('mytemplate_use_pages') == 'false') query_posts("showposts=$featured_num&cat=".get_cat_ID($featured_cat));
    else {
        global $pages_number;

        if (get_option('mytemplate_feat_pages') <> '') $featured_num = count(get_option('mytemplate_feat_pages'));
        else $featured_num = $pages_number;

        query_posts(array
                        ('post_type' => 'page',
                        'orderby' => 'menu_order',
                        'order' => 'ASC',
                        'post__in' => get_option('mytemplate_feat_pages'),
                        'showposts' => $featured_num
                    ));
    } ?>
            <!-- Start my loop to display everything-->
    <?php if (have_posts()) : while (have_posts()) : the_post();
    global $post; ?>

So far, I’ve made it a little more consise, but can’t get over the last little bit of how to combine the parameters to say query_posts(getMyPostsArray().AddList(ohINeedACouplePagesToo())) //Yes, I know this looks like C# or something…I’m not a PHP guy..

here’s the code in a little more readable version that’s closer to what I want:

            $featured_cat = get_option('mytemplate_feat_cat'); 
                //I combined featured_num to get the total number of featured items to display
        $featured_num = get_option('mytemplate_featured_num') + count(get_option('mytemplate_feat_pages'));; 

query_posts("showposts=$featured_num&cat=".get_cat_ID($featured_cat));

            //I think this second line overwrites the first query_posts() :-/
            query_posts(array
                            ('post_type' => 'page',
                            'orderby' => 'menu_order',
                            'order' => 'ASC',
                            'post__in' => get_option('mytemplate_feat_pages'),
                            'showposts' => $featured_num
                        ));
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T22:21:13+00:00Added an answer on May 17, 2026 at 10:21 pm

    Ryan, why don’t you just go ahead with two queries and two loops?

    query_posts("post_type=post&showposts=3");
    while (have_posts()) { the_post(); }
    
    query_posts(array(
        "post_type" => "page",
        "post__in" => get_option("mytemplate_feat_pages"),
        "showposts" => 5
    ));
    while (have_posts()) { the_post(); }
    

    If you need a certain number of posts and pages to fill in the space, you can also use $wp_query->found_posts to actually calculate what you have and what you need. This would probably be the easiest solution, since even if you can get posts and pages in SQL, you might have a hard time ordering them, since posts don’t have a menu order, while you wouldn’t like pages ordered by publish date.

    Hope that helped,
    Cheers!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

That's pretty much it. I'm using Nokogiri to scrape a web page what has
I've got a string that has curly quotes in it. I'd like to replace
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
Basically, what I'm trying to create is a page of div tags, each has
I'm making a simple page using Google Maps API 3. My first. One marker
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.