excluding pages from search results


 

Current User: Guest Login Register
Please consider registering

Search 
Search Forums:


 




excluding pages from search results

Add a New Topic Reply to Post
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 231

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

Cry

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

9:55 pm
August 5, 2007


Jean-Luc

Admin

posts 231

Luis,

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

<? } ?>

by :

<?php } ?>

Jean-Luc

Add a New Topic Reply to Post


Reply to Topic: excluding pages from search results

NOTE: New Posts are subject to administrator approval before being displayed

Guest Name (Required):

Guest EMail (Required):

Guest URL (required)

Math Required!
What is the sum of: 9 + 8        (Required)

Topic Reply:


 

WebStats1


About the InternetOfficer.com forum

Currently Online:

3 Guests

Maximum Online: 31

Forums:

Groups: 2

Forums: 7

Topics: 109

Posts: 516

Members:

There are 29 members

There are 95 guests


Jean-Luc has made 231 posts

Top Posters:

Steve - 14

angelko - 5

cwei - 4

KevinA - 3

Kinglui - 3

Administrator: Jean-Luc | Moderators: Jean-Luc


© Simple:Press Forum - Version 3.1.2 (Build 340)