[Resolved] Get Terms CPT does not work with Elements

Home Forums Support [Resolved] Get Terms CPT does not work with Elements

Home Forums Support Get Terms CPT does not work with Elements

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #1972050
    FunkyCss

    Hi there,

    I have created a CPT product_categories and I try to hook the query ,

    The hook works just fine, <?php do_action( ‘generate_before_main_content’ ); ?>

    My issue is that the PHP inside does not work. ( I have enabled the php in the hook )

    My code

    	<?php
    				$terms = wp_get_post_terms( $post->ID, 'product_category');
    					foreach ( $terms as $term ) {
    					$term_link = get_term_link( $term );
    					echo '<div class="product-category"> <a class="solo-category" href="' . $term_link . '">' . $term->name . '</a></div>' . ' ';
    				}
    				?>

    Take notice , if paste this code inside the custom template it works just fine but with Elements will show nothing.

    #1972119
    David
    Staff
    Customer Support

    Hi there,

    try adding: global $post; at the top of your code.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.