• this code search in wordpress by title and order by ‘rubro’;
    but not search by name of the ‘rubro’
    help please

    $prepare_query = "SELECT * FROM $wpdb->posts AS p LEFT JOIN $wpdb->term_relationships AS r ON (p.ID = r.object_id) INNER JOIN $wpdb->term_taxonomy AS x ON (r.term_taxonomy_id = x.term_taxonomy_id) INNER JOIN $wpdb->terms AS t ON (r.term_taxonomy_id = t.term_id) WHERE p.post_type IN ('post', 'publicacion') AND p.post_status = 'publish' AND x.taxonomy = 'rubro' AND p.post_title LIKE %s ORDER BY t.name ASC, p.post_date DESC";

    • This topic was modified 5 years, 2 months ago by romemarce.
Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    (@bcworkz)

    You need to join in the terms table by term_id from term_taxonomy. Then you can add something like AND terms.name = 'rubro'

Viewing 1 replies (of 1 total)
  • The topic ‘Search post by name taxonomy or post_title’ is closed to new replies.