query for WPSEO metadesc for several category IDs
-
I want to return the value of the WPSEO metadesc for several categories on a page in my site can anyone provide me with code to get that data? I can get the WPSEO meta title fine but the metadesc never is returned.
This all works except for the metadesc:
add_shortcode( ‘catDisplay’, ‘catDisplay’ );
function catDisplay(){
ob_start();$prod_categories = get_terms(array(
‘taxonomy’ => ‘product_cat’,
‘orderby’ => ‘include’,
//’order’ => ‘ASC’,
‘hide_empty’ => 1,
‘depth’ => 1,
‘include’ => array( 114,104,305,66,29 )
));echo “<div class=’row’>”;
foreach( $prod_categories as $prod_cat ){
$cat_name = $prod_cat->name;
$cat_id = $prod_cat->term_id;
$meta = get_post_meta(‘_yoast_wpseo_metadesc’, true);
$seoTitle = $meta[‘product_cat’][$cat_id][$meta];
$cat_thumb_id = get_woocommerce_term_meta( $prod_cat->term_id, ‘thumbnail_id’, true ); //establishes category thumbnail ID
$cat_thumb_url = wp_get_attachment_thumb_url( $cat_thumb_id ); //uses category ID to get category thumbnail
$term_link = get_term_link( $prod_cat, ‘product_cat’ );
echo “<div class=’col-md-4 col-sm-4′><h4>”.$cat_name.”</h4>“.$seoTitle.”</div>”;
}
echo “</div>”;
wp_reset_query();return ob_get_clean();
}
- The topic ‘query for WPSEO metadesc for several category IDs’ is closed to new replies.