如果您在术语归档页面中,则实际上设置了分类法和术语。你可以钩住wp_head
在函数中添加打开的图形。php:
add_action( \'wp_head\', \'wpse_wp_head\' );
function wpse_wp_head () {
//First, we check if we are in our custom taxonomy
if( is_tax(\'my-custom-taxonomy\') ) {
$taxonomy_slug = get_query_var( \'taxonomy\' );
$term_slug = get_query_var( \'term\' );
$term_url = get_term_link( $term_slug, $taxonomy_slug );
//Add Open Graph property
echo \'<meta property="og:url" content="\'. esc_url( $term_url ) .\'">\';
//If you need the full object of current term
//$term = get_term_by( \'slug\', $term_slug, $taxonomy_slug );
//Now you can get all the term data. For example:
//$term->name, $term->term_id, $term->slug,.....
}
}