Search post how do not have "moretag" (2 posts)

  1. Commentguerir
    Posted 2 years ago #

    Hi all,

    Please need a code that can display all post that have not the <!--more--> tag ?

    is it possible ? thank's

  2. bcworkz
    Posted 2 years ago #

    The SQL query to do this is:

    SELECT *
    FROM wp_posts
    WHERE post_content NOT LIKE '%<!--more-->%'
    AND post_status = 'publish'
    AND post_type = 'post'

    Substitute the "wp_" with your prefix or if using $wpdb use $wpdb->posts .You can't use WP_Query alone because NOT LIKE is not supported. You could use WP_Query to set up everything else, then use the 'posts_where' filter to add in the NOT LIKE clause. This way you can paginate the results. Using the SQL query and $wpdb would mean you're on your own for pagination.

Topic Closed

This topic has been closed to new replies.

About this Topic