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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:45:35+00:00 2026-05-26T20:45:35+00:00

is there a way to just search pages Custom Types Posts I am currently

  • 0

is there a way to just search

  • pages
  • Custom Types
  • Posts

I am currently modifying the twenty eleven theme.

here is the Code for search.php:

<?php if ( have_posts() ) : ?>

            <header class="page-header">
                <h1 class="page-title"><?php printf( __( 'Search Results for "%s"', 'twentyeleven' ), '<span>' . get_search_query() . '</span>' ); ?></h1>
                <div class="SearchCount"><?php /* Search Count */ 
                $allsearch = &new WP_Query("s=$s&showposts=-1"); 
                //$key = wp_specialchars($s, 1); 
                $count = $allsearch->post_count; _e(''); _e(); 
                    echo $key; _e(); _e(); 
                    echo $count . ' '; _e(''); 
                wp_reset_query(); ?> Saved Results </div>
                <div id="topPagination"><?php twentyeleven_child_content_nav( 'nav-above' ); ?></div>
            </header>

            <?php /* Start the Loop */ ?>
            <?php while ( have_posts() ) : the_post(); ?>

                <?php
                    /* Include the Post-Format-specific template for the content.
                     * If you want to overload this in a child theme then include a file
                     * called content-___.php (where ___ is the Post Format name) and that will be used instead.
                     */
                    get_template_part( 'content', 'search' );
                ?>

            <?php endwhile; ?>

            <?php twentyeleven_child_content_nav( 'nav-below' ); ?>

        <?php else : ?>

            <article id="post-0" class="post no-results not-found">
                <header class="entry-header">
                    <h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
                </header><!-- .entry-header -->

                <div class="entry-content">
                    <p><?php _e( 'Sorry, but nothing matched your search criteria. Please try again with some different keywords.', 'twentyeleven' ); ?></p>
                    <?php get_search_form(); ?>
                </div><!-- .entry-content -->
            </article><!-- #post-0 -->

        <?php endif; ?>

And here is the content-search.php

<h2><a href="<?php the_permalink();?>"> 
        <?php $title = get_the_title(); $keys= explode(" ",$s); $title = preg_replace('/('.implode('|', $keys) .')/iu', '<strong class="search-excerpt">\0</strong>', $title); ?>
        <?php echo $title; ?>
    </a><br />
<span class="categoryClass"><?php the_category(','); ?></span></h2>

    <?php the_excerpt(); ?>
    <?php wp_link_pages( array( 'before' => '<div class="page-link"><span>' . __( 'Pages:', 'twentyeleven' ) . '</span>', 'after' => '</div>' ) ); ?>
</div><!-- .entry-content -->

Thank you

  • 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-26T20:45:36+00:00Added an answer on May 26, 2026 at 8:45 pm

    The way I see it you have two options. One is to modify wp_query to only return the type that you want. The second is search on everything, but filter the results afterwards.

    This is how I believe you would modify wp_query by using Type Parameters

    $allsearch = &new WP_Query("s=$s&showposts=-1"); //what you currently have
    $customsearch = &new WP_Query("post_type=page&posts_per_page =5");
    

    This is how I believe you would filter post search

    if ( have_posts() ) : while ( have_posts() ) : the_post();
       if (is_page()) {} //do something if page
    endwhile;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a way in Ant to just use regex to search through a
Is there any way (just out of curiosity because I came across multiple same-value
Is there a way just like multidatatrigger behavior of WPF also implemented in Silverlight
Is there any way to get just a part from MySql cell and ignore
I just wonder there a way to display the files in document directory with
Is there any way can declare a bean in just like JSP UseBean in
I am just curious is there any way to determine if a particular module
Is there a way to tell ifort or gfortran to just try to parse
Is there any way to make a DataTemplate reference itself just from XAML? In
Is there a way to create a second Desktop screen in C# - just

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.