Support

Account

Home Forums Bug Reports Bug regarding fields on custom taxonomies

Solved

Bug regarding fields on custom taxonomies

  • I seem to have stumbled upon a problem regarding related posts on taxonomies.

    I am currently setting up a webshop using woocommerce, and i need a realtion to a blog page from within the product.

    So ive setup a relation from within my brands to a brandpage via the relation widget.

    $brand = get_the_terms($product->ID, 'product_brand');
    $brand = reset($brand);
    if( sizeof( $brand ) != 0 ){
    	$brandId = (int)$brand->term_id;
    	get_field('brand_relation', $brandId);
    }

    Just returned a false, but after a bit of fiddling ive found that ACF adds a option to the database relating to the post.

    So my solution were as follows.

    $brand = get_the_terms($product->ID, 'product_brand');
    $brand = reset($brand);
    if( sizeof( $brand ) != 0 ){
    	$brandId = (int)$brand->term_id;
    
    	$brandPostId = get_option('product_brand_' . $brandId . '_brand_taxonomy_relation');
    
    	$relatedPost = get_post($brandPostId[0]));
    
    }

    Dont know if this is a bug, but i couldt seem to find a solution in here.

  • Hi @lennarto

    It is always important to read the docs. In particular, the tutorial which covers how to load data from a taxonomy term:

    You have used an incorrect $post_id parameter, that is what the problem is:

    http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-taxonomy-term/

    Thanks
    E

  • Oooh, yea, ive must have been in quite a caffine haze when searching!

    Thanks Elliot.

Viewing 3 posts - 1 through 3 (of 3 total)

The topic ‘Bug regarding fields on custom taxonomies’ is closed to new replies.