WordPress.org

Ready to get started?Download WordPress

Forums

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

  1. dudd
    Member
    Posted 8 months 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
    Member
    Posted 8 months 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.

Reply

You must log in to post.

About this Topic

Tags