• Hello, when I write this sql code, it shows me the same post 5 times.

    $wp_query->request = "SELECT * FROM $wpdb->posts
    	LEFT JOIN $wpdb->postmeta ON($wpdb->posts.ID = $wpdb->postmeta.post_id)
    	LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
    	LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
    	LEFT JOIN $wpdb->terms ON($wpdb->terms.term_id = $wpdb->term_taxonomy.term_id)
    	WHERE $wpdb->terms.slug = 'categoryname'
    	AND $wpdb->term_taxonomy.taxonomy = 'category'
    	AND $wpdb->posts.post_status = 'publish'
    	AND $wpdb->posts.post_type = 'post'
    ORDER BY $wpdb->posts.post_date DESC";
    
    $pageposts = $wpdb->get_results($wp_query->request, OBJECT);
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Display posts by custom select query problem’ is closed to new replies.