Custom taxonomies – get_term_id (1 post)

  1. Arnii
    Posted 5 years ago #

    I have a huge problem I was hoping a clever mind could figure out – I already spent 2 days on this issue.

    I'm using the plugin "More Taxonomies" to create a new tag-"category" called Personas. Everything is working fine, but I cannot to use these tags to look related posts.

    What I want is to get the custom taxonomy id of the current post, put that into a variable, and let that variable work as the tag that's is being looped.

    The code looks like this right now (it's the varible $term_id I need to somehow call dynamically, based on the current post);

    $taxonomy = "'persona'";
    $term_ids = "($term_id)";
    $post_status = "'publish'";
    $post_type = "('post', 'page', 'live')" ;

    $query = "SELECT $wpdb->posts.* FROM $wpdb->posts
    INNER JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)
    INNER JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
    WHERE 1=1
    AND $wpdb->term_taxonomy.taxonomy = $taxonomy
    AND $wpdb->term_taxonomy.term_id IN $term_ids
    AND $wpdb->posts.post_type IN $post_type
    AND $wpdb->posts.post_status = $post_status
    GROUP BY $wpdb->posts.ID
    ORDER BY $wpdb->posts.post_date DESC";


    if ($my_posts) {
    foreach($my_posts as $post) if( $post->ID == ''.$thePostID.'' ) continue; {

    <?php the_post_thumbnail( 'thumbnail' ); ?>

    <?php }

    Any help is highly appreciated...


Topic Closed

This topic has been closed to new replies.

About this Topic