简体   繁体   中英

How to create a custom MySQL query to display WordPress posts (no wpquery)?

I wanted to create a Java application which displays WordPress posts. So is there any way I can display WordPress posts without wp_query using actual MySQL query?

Adjust the query according your usage.

$querystr = "
        SELECT wp_posts.* 
        FROM wp_posts, wp_postmeta
        WHERE wp_posts.ID = wp_postmeta.post_id 
        AND wp_postmeta.meta_key = 'tag' 
        AND wp_postmeta.meta_value = 'email' 
        AND wp_posts.post_status = 'publish' 
        AND wp_posts.post_type = 'post'
        AND wp_posts.post_date < NOW()
        ORDER BY wp_posts.post_date DESC
     ";

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM