Rik de Vos
Rik de Vos

Reputation: 3517

Wordpress - Hide specific posts

I am writing a wordpress plugin and I want to hide posts/pages which contain a specific string in their title.

For example, I want to hide all the posts/pages where the title contains: [something123]

show this post/page "Lorem Ipsum"
hide this post/page "Lorem Ipsum [something123]"
hide this post/page "Hello World [something123]"
show this post/page "Hello World"

Upvotes: 0

Views: 846

Answers (1)

mrtsherman
mrtsherman

Reputation: 39872

In your theme directory find loop.php

In it there should be a line like this

<?php while ( have_posts() ) : the_post(); ?>

pseudocode:

if (get_the_title() contains "") { endwhile; }

http://codex.wordpress.org/Function_Reference/get_the_title

You could also use a filter:

http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where

Although I don't feel like writing one for you =). Maybe somebody else will.

Upvotes: 1

Related Questions