If you are in term archive page, the taxonomy and term is actually set. You could hook wp_head to add the open graph in your functions.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,.....
}
}
Related Posts:
- Check if a post has any term in this custom taxonomy?
- Contact Form 7 – Populate Select List With Taxonomy [closed]
- Why is my working Custom Taxonomy not in get_taxonomies array?
- Custom taxonomy hide meta box but show in menu
- display posts with same taxonomy term
- Is there a way to disable a term rather than deleting it?
- How do I filter posts by taxomony using AJAX
- SQL QUERY needed to get POST category (taxonomy) ? – MUST be SQL statement
- Remove Category description textarea
- Create taxonomy with meta term using the WP Rest Api
- How can I set up a category “overview” page?
- Sort posts by number of matched terms
- Possible to register multiple custom taxonomies in one function?
- Taxonomies not appearing in columns on dashboard
- How to modify default taxonomy field to a single text field?
- How to set hierarchical terms to a post using wp_set_object_terms
- Echo taxonomy term meta on author.php
- Hierarchical display of custom taxonomy
- How to output the taxonomy term name in a widget
- List taxonomy / category count showing list published posts only
- Advanced Tax Query
- Function to limit the number of posts in taxonomy.php
- Is It Possible To Have Shared WordPress Custom Post Types?
- WordPress renames slug of tags used in multiple taxonomies?
- User role permissions based on taxonomies
- WP Query with custom taxonomy
- How to prevent posts duplicating when viewing a custom taxonomy term
- get_the_terms() to show all custom taxonomies
- Custom taxonomies making WP very slow – Way to fix?
- Get Taxonmy Term ID For Current Post
- meta_key & meta_value not working with get_pages and custom taxonomy
- Is it possible to create exclusive custom taxonomy?
- wp_insert_post not updating custom taxonomy selected if logged in as a subscriber
- Changing stylesheet depending on custom taxonomy terms
- Taxonomy with_front causes all
- Taxonomy archive showing no results
- Autogenerate Front End Form Field With jQuery
- Changing taxonomy term by slug (wp_update_term)
- Taxonomy template shows only 10 posts
- What is faster: custom taxonomy or serialized post-meta for db retrieval? (over 60,000 posts)
- Rewrite Rule Working for all but one of the taxonomies created
- Get taxonomy based on another taxonomy slug
- Extend & Search Native WordPress Image Galleries With Tags and Taxonomies?
- How to Rewrite Taxonomy URL to Include the Post Type as the Second Segment of the URL?
- How to get all taxonomies which can be added in menu?
- WordPress Tag or Custom Taxonomy Return All Posts if has that Word in Post Title
- woocommerce custom product category template
- Custom Taxonomy index/archive hierarchy
- Filter custom taxonomy archive posts by 2nd custom taxonomy using select dropdown
- How to show all post related taxonomies
- Multi-select field for Taxonomy can’t save the value
- Create custom taxonomy and Display in metabox dropdown
- How to create a custom taxonomy using a shortcode?
- Override Taxonomy Template
- How Parent Taxonomy automatically added to the post when using `wp_set_object_terms()`?
- Trying to add taxonomy to get_categories() but it’s not working. How to fix this?
- Filter through custom taxonomy with an array of taxonomy IDs
- Dropdown taxonomy lists in admin menu
- Taxonomy archive template that shows posts from more than one taxonomy
- Taxonomy Overview Page?
- Order taxonomy terms wordpress
- Unable to get the Parent Custom Taxonomy Terms
- How to get the term description in a taxonomy term archive query?
- How to define %category% for custom taxonomies?
- Unsetting post_tag taxonomy breaks term description for other taxonomies
- Taxonomies on Pages with Custom Formatting
- Why do my quick edits for custom taxonomies not show on the post frontend?
- Prioritise Pages over Taxonomy Term Root Archive, but not Taxonomy Term Child Archives
- Tracking the name of a custom taxonomy
- new custom filed not showing in taxonomy
- How do I get the correct URL?
- Custom Taxonomies Archive Page 404
- How to replace custom post type with custom taxonmy in permalinks
- Cloning product not copying custom taxonomies
- How To Create Dynamic Permalink To Custom Taxonomy List of Current Posts?
- Dropdown (with onChange) with custom taxonomies
- Get Highest and Lowest get_term_meta() value from Taxonomy Term
- ACF Custom field not showing in Timber Taxonomy page
- How to get a terms and posts associated with another term?
- Displaying subcategories and then posts in taxonomy template
- Ignore punctuation marks in taxonomy order by name
- How to use two same taxonomy in same post differently?
- Sort Taxonomy List by Custom Values
- How do you search for a post by custom taxonomy?
- Display taxonomy term slugs
- Can I use multi (sub) levels of relation (AND | OR) on custom query?
- How to display custom taxonomy
- Index page of posts tagged with two separate taxonomies
- How to use tax_query other than by slug or id or solve custom taxonomy tags conflicts with pre-existing tags?
- Taxonomy term breadcrumb; how?
- add custom fields in custom taxonomy meta box in wordpress-3.5.2
- How to permanently delete a taxonomy
- Advanced AND tax_query in sidebar with 2 taxonomies
- Alternative for is_taxonomy() to workaround theme’s default sidebar
- Display woocommerce product_cat child terms with thumbnails
- query grandchildren taxonomy terms
- Adding new terms to custom taxonomy
- Add custom display condition to Elementor Theme Builder for custom taxonomy children, grandchildren, and great-grandchildren
- Add text in custom taxonomy
- How do I check if a post has a term with a particular ancestor/parent?