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 8224379
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:03:05+00:00 2026-06-07T15:03:05+00:00

I have a WordPress Installation. I have about 3 x custom post types on

  • 0

I have a WordPress Installation. I have about 3 x custom post types on my site. When I do a search, all post type results get displayed on the front end on 1 page. Some post types are totally different from others content wise so the results look a bit funny.

Is there a way to split the results into tabs according to post type? I want to leave the results as default the way they are now (All Results) but then have tabs to the right filtering out the different results according to post type they belong to.

I created a jpeg here to help explain exactly what I am trying to do.

Thanks

http://f.cl.ly/items/110S2K1A0T3m290Y0C14/Filter_post_Types.jpg

enter image description here

Update 1:
Just wanted to add a bit more info on the code side

I was planning on using shortcodes as tabs

[tabs]
[tab]All Search Results[/tab]
[tab]Post Type 1 Results[/tab]
[tab]Post Type 1 Results[/tab]
[tab]Post Type 1 Results[/tab]
[tab]

or in PHP Template I can also do it by

<?php 

echo do_shortcode('[tabs style="boxed" id="searchTabs"]
   [tab title="Post Type 1"]Post Type 1 Results[/tab]
   [tab title="Post Type 2"]Post Type 2 Results[/tab]
   [tab title="Post Type 3"]Post Type 3 Results[/tab]
   [/tabs]');

?>

I am thinking there is something here that can help me, but not sure how to implement it http://codex.wordpress.org/Template_Tags/get_posts

Update 2:
Other advice I have received on another forum is to try code like this, but I cannot seem to implement it correctly to my search template php which is here http://pastie.org/4248751

The code suggested was

<?php
$the_slug = 'my_slug';
$args=array(
  'name' => $the_slug,
  'post_type' => 'custom_post_Type_1',
  'post_status' => 'publish',
  'numberposts' => 1
);
$my_posts = get_posts($args);

$the_slug2 = 'my_slug2';
$args2=array(
  'name' => $the_slug2,
  'post_type' => 'custom_post_Type_2',
  'post_status' => 'publish',
  'numberposts' => 1
);
$my_posts2 = get_posts($args2);

echo do_shortcode('[tabs style="boxed" id="searchTabs"]

   [tab title="Post Type 1"]
        <?php //This code is for first post type
        foreach( $myposts as $post ) :  setup_postdata($post); ?>

            <li><a>"><?php the_title(); ?></a></li>

        <?php endforeach; ?>
   [/tab]

   [tab title="Post Type 2"]
       <?php //This code is for second post type
       foreach( $myposts2 as $post ) :  setup_postdata($post); ?>

            <li><a>"><?php the_title(); ?></a></li>

        <?php endforeach; ?>
   [/tab]

   [/tabs]');
?>
  • 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-06-07T15:03:07+00:00Added an answer on June 7, 2026 at 3:03 pm

    EDIT: Sorry – understand now.

    User different loops in each tab.

    First tab:

    <?php 
    global $post; 
    rewind_posts();
    $query = new WP_Query(array(
     'posts_per_page' => -1,
    ));
    while ($query->have_posts()) : $query->the_post(); 
    ?>
    
    <!-- YOUR OUTPUT CODE HERE -->
    
    <?php 
    endwhile; 
    wp_reset_postdata();
    ?>
    

    Each other tab would have the same loop, but with an added parameter in the query

    <?php 
    global $post; 
    rewind_posts();
    $query = new WP_Query(array(
     'posts_per_page' => -1,
     'post_type' => 'post_type_name',
    ));
    while ($query->have_posts()) : $query->the_post(); 
    ?>
    
    <!-- YOUR OUTPUT CODE HERE -->
    
    <?php 
    endwhile; 
    wp_reset_postdata();
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a wordpress installation I'd like to get rid off. It's been constant
I have a WordPress installation on my site, and I want to display WP
I have a wordpress site, it's already have about about 3000 published posts, the
my Wordpress installation is placed in the directory named /wordpress. I have activated custom
I have a wordpress installation with some plugins and a custom theme. On one
i have wordpress blog in my custom built website, i am displaying some posts
I have wordpress a site with a customized login page, the problem is when
i have an wordpress site and it have menus over there. what i want
I have a WordPress site which have 4 pages with one page is a
I have a Wordpress site (installed in root) and a Simple Machines Forum (in

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.