Support » Plugins and Hacks » Not showing certain post filter the post

  • Hello,
    I’m working on a plugin that filters certain posts from showing. How can i filter posts with a certain title from not showing up all together using a plugin in the post list?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Something like this should do what you’re after:

    function strike_title($where) {
    global $wpdb;
    $title = 'I hate this post!';
    $where .= " AND $wpdb->posts.post_title != '$title' ";
    return $where;
    }

    add_filter('posts_where', 'strike_title');

    Note here the add_filter(), which flips our SQL query fragment onto the posts_where API hook.

    It works! Your a genius.

    Can i use the posts.post_title for example examining the post_content ?

    Also, How can i return a value from an enum?

    Lets say i want to see if the post comment is ‘spam’ or not.
    when i tried

    $commentstatus = ‘spam’

    $where .= ” AND $wpdb->comments.comment_approved != ‘$commentstatus’ “;

    it gives me an sql error, is the enum value should be read diffrently?

    Can i use the posts.post_title for example examining the post_content ?

    I guess you could. If you are working on individual post objects though, you’d be better off scoping $post to global and accessing a post’s content like so:

    $post->post_content

    Also, How can i return a value from an enum?

    Note that ‘posts_where’ is the plugin API hook for the WHERE clause of the *posts* table query. I’m not aware of a similar hook for comments.

    Im not tryin to pull the data from the comment, I just gave an example.

    I save data for each post on an external table.

    I use the $wpdb.metainfo.priority != ‘p1’; for example and it does not work because the field is enum and not text. How can i select that field? i saw that i need to select the post_id first and then the priority or somethin like that?

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Not showing certain post filter the post’ is closed to new replies.