You must be logged in to post Login


Lost Your Password?

Search Forums:


 






Minimum search word length is 4 characters – Maximum search word length is 84 characters
Wildcard Usage:
*  matches any number of characters    %  matches exactly one character

excluding pages from search results

UserPost

9:41 am
June 24, 2007


Tom

Guest

Hi

Thanks for the plugin. I have one quick question – is there any way of excluding certain pages from appearing in search results? If not, perhaps this is something that could be added to a future version of the plugin?

Tom

10:25 am
June 24, 2007


Jean-Luc

Admin

posts 1125

Hi Tom,

You can edit your search.php and add a condition on the post or page numbers in the loop, like this:

<?php while (have_posts()) : the_post(); ?>
<?php if ($post->ID !='19') { ?>

The contents of the loop is here.

<?php } ?>
<?php endwhile; ?>

 

In this example, post 19 will be excluded from the search.

I agree it would be much nicer to do that without edition of the files of the theme.

Jean-Luc

2:23 am
July 17, 2007


Chris

Guest

<ol>
<?php while (have_posts()) : the_post(); ?>
<?php if ($post->ID =='11') {
} elseif ($post->ID =='74') {
} elseif ($post->ID =='75') {
} elseif ($post->ID =='76') {
} elseif ($post->ID =='77') {
} elseif ($post->ID =='78') {
} elseif ($post->ID =='79') {
} elseif ($post->ID =='80') {
} elseif ($post->ID =='90') {
} elseif ($post->ID =='91') {
} elseif ($post->ID =='93') {
} elseif ($post->ID =='119') {
} else {
?>
<li><h5><a href="<?php the_permalink() ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h5></li>
<? } ?>
<?php endwhile; ?>
</ol>

 

That will do it if you have multiple search pages that you want to not show. 

– Chris Cagle

Cagintranet Web Design

 

9:34 pm
August 5, 2007


Luis

Guest

Chris,

I just get the error

Parse error: parse error, unexpected T_ENDWHILE in \\www\\wp-content\\themes\\latitude14\\search.php on line 29

I would like to exclude about 10 posts from search results.

9:55 pm
August 5, 2007


Jean-Luc

Admin

posts 1125

Luis,

It seems that some loop is not properly terminated. I would replace :

<? } ?>

by :

<?php } ?>

Jean-Luc


About the InternetOfficer.com Forum

Forum Timezone: UTC 1

Most Users Ever Online: 302

Currently Online:
12 Guests

Currently Browsing this Topic:
1 Guest

Forum Stats:

Groups: 2
Forums: 9
Topics: 638
Posts: 2712

Membership:

There are 257 Members
There have been 305 Guests

There is 1 Admin
There is 1 Moderator

Top Posters:

cssfsu – 55
deepakgupta – 34
albert_newton – 30
cosminpana – 20
DTNMike – 19
ahtshun83 – 17

Recent New Members: raju, todd2taylor, sbdcunha, mansigill1987, ThomasDuh, ThomasKic

Administrators: Jean-Luc (1125 Posts)

Moderators: Jean-Luc (1125 Posts)