WordPress.org

Ready to get started?Download WordPress

Forums

W3 Total Cache
get_the_terms not returning object_id when caching is activated (1 post)

  1. MeinLife
    Member
    Posted 1 year ago #

    I have a custom function in a custom plug-in that is breaking with object caching

    The function is calling get_the_terms and when W3 Total Cache is disabled it returns the expected array with the last item in the array being object_id, however when I enable the plug-in it still returns the array, however the object_id is missing from the array and consequently breaking the rest of my plug-in

    I am at a complete loss here ... any ideas are greatly appreciated ... and please let me know if you need any more info to trouble shoot ... below are the function that is calling it, and the array it is returning with and without the plugin activated

    Thanks!

    function getStepDataByPostID($taxonomy, $target_taxonomy, $term_slug, $post_in = array()) {
    
    	$args = array(
        'post_type'=> 'getstarted',
        'posts_per_page' => -1,
        'taxonomy' => $taxonomy,
        'term' => $term_slug,
        'post__in' => $post_in,
        'order'    => 'ASC'
        ); 
    
    	$arr = array();             
    
    	$the_query = new WP_Query( $args );
    
    	if($the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post();
    		$terms = get_the_terms($post->ID, $target_taxonomy);
    
    		$count = count($terms);
    		if ( $count > 0 ) {
    			foreach ($terms as $term) {
    				$arr[] = $term->object_id;
    			}
    		}
    
    	endwhile;
    	endif; 
    
    	wp_reset_postdata();
    
    	return $arr;
    
    }

    With caching turned off it returns
    [67] => stdClass Object
    (
    [term_id] => 67
    [name] => Marketing
    [slug] => marketing
    [term_group] => 0
    [term_taxonomy_id] => 67
    [taxonomy] => get_started_role
    [description] =>
    [parent] => 0
    [count] => 76
    [object_id] => 989
    )

    With caching turned on it returns:
    [0] => stdClass Object
    (
    [term_id] => 67
    [name] => Marketing
    [slug] => marketing
    [term_group] => 0
    [term_taxonomy_id] => 67
    [taxonomy] => get_started_role
    [description] =>
    [parent] => 0
    [count] => 76
    )

    http://wordpress.org/extend/plugins/w3-total-cache/

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic

Tags

No tags yet.