How to run select query of post with category and tags?

Question

I want to fetch multiple posts with categories and tags
currently I’m using this query:

$pagesize = 20;
$pageNumber = 1;

$mysql = mysqli_query($con,"SELECT p.post_title,
     p.ID,
     p.post_content,
     p.post_date,
     p.post_name as url,
     t.name as category_name
FROM wp_posts p,
     wp_terms t,
     wp_term_relationships r,
     wp_term_taxonomy tt
WHERE p.post_status='publish' AND
     tt.taxonomy = 'post_tag' AND
     p.id=r.object_id AND
     r.term_taxonomy_id=tt.term_taxonomy_id AND
     tt.term_id = t.term_id
ORDER BY p.post_date desc 
LIMIT ".(int)($pageNumber*$pageSize).",".(int)$pageSize."") or die ("error".mysqli_error($con));

The mysqli-connection works. But when I run this code, I only get a blank page. How can I fix this?

0
, , , Mohnish 2 years 2020-08-17T21:10:20-05:00 0 Answers 47 views 0

Leave an answer

Browse
Browse