I think you need to do the add_action( 'wp_head', 'add_meta_tags' , 10 );
in your functions.php instead of the template to get the function called. And it adds it then everywhere where you have wp_head()
. So if you want to only call it content-share.php you need some conditioning logic like
if (is_page_template('page-templates/content-share.php')) {
add_action( 'wp_head', 'add_meta_tags' , 10 );
}
Of course change the page-templates folder to be what ever the folder is where you have the template in your theme folder.
Related Posts:
- How do I find the code executed when wp_head() is called?
- custom COOKIE on custom page
- remove_action on after_setup_theme not working from child theme
- Add tags to the section via functions.php
- Remove Actions/Filters added via Anonymous Functions
- Trying to use add_action and do_action with parameters
- Check if post is being published for the first time, or is an already published post being updated
- How to use the do_action () with parameter
- Perform an action when post is updated/published
- WordPress Theme Update Action?
- Extract image from content and set it as the featured image
- Do WordPress’ cron’s clean up expired transients?
- add_action in a function, is it possible?
- Using a private method as an action callback from within a class
- Refresh page after form action
- How to restrict actions and filters “properly” by conditions
- How to count number of functions attached to an action hook?
- Add action hook conditionally – only when home.php in use
- Using add_filter() in Widgets
- How can I tell if I’m on a login page? [duplicate]
- Add options to featured image
- Use add_action within template
- Problem in using Customizer
- Problem with custom function when I go back with the browser
- Replace admin header logo with an image
- New checkbox in custom widget isn’t saving data
- Function to echo (or display?) wordpress tags in the head section
- colorbox not loading in
- template_redirect action only firing if logged in
- Facebook OpenGraph error, Call to undefined function wp_get_attachment_src()
- How to avoid saving empty data to sql while using add_meta_box
- How to change text color depending on the number value (Using javascript)
- How to use wp_enqueue_script properly?
- How to add custom metakey to shop_order page’s searching function?
- Using get_terms for custom taxonomy in functions.php
- Issue passing action class to nested function. Admin Columns
- Does hook have an effect on increasing the page load?
- How to Override Page Template if URL matches query?
- Save_post – Warning: Cannot modify header information
- What is the earliest Hook a Script can use?
- How do I trigger WP CLI DB export using a PHP function?
- If has action not working as expected
- Update wp_postmeta table based on 2 keys
- Modifying a WordPress Plugin
- Hide author info in single posts by certain users
- post value to function with Ajax and jQuery
- Is_Page doesnt detect my page
- How do you insert code into the sidebar?
- How Do I Unhook This Parent Theme Function?
- blank page with wp_get_attachment
- How to show only specific category post by user role without plugin and restrict all other cats
- Postback redirect through add_action is not triggered
- use add_action in a shortcode (gravity form – WordPress)
- wp_footer hook causing text to show on bottom of page
- Reference multiple style sheets, clearing styles for permalink page, custom fields for css
- Remove action hook from Class, understanding OOP
- How to change form action of wp-login page with a function
- How To Display Author Popup on Entry Meta (Genesis Framework)?
- Creating a “Related Meta” type field?
- Which method is more correct for removing WooCommerce Extensions menu item?
- Remove post from latest posts after a month only with certain tag
- save_post doesn’t correctly process function call with php class
- Placing CSS/ JS into the header or footer (inline) – trying to apply to several templates
- WordPress hooks to call a function inside a construct
- Edit meta fields from within template
- True parameter but jquery register in header and not in the footer with wp_register_script
- Return ACF Field value function
- Fatal error: Call to undefined function add_action() – an untouched problem
- Sending Messages Back to the Template After Processing?
- Pass arguments to function class with do_action()
- previous_post_link inside of a function?
- update_post_meta not working in function
- What add_action reference should I be using or should I use do_action?
- How To Get WordPress Categories Last Update Date?
- How to add a meta information to the URL?
- Getting error while trying to use custom comment function
- Settings in functions.php used by a plugin
- Automatically add custom fields (post_meta) to all published posts, hourly, via wp_cron?
- Conditionally write open graph meta property in header
- Echo a div to header.php from functions.php
- function to return comma separated list of meta values
- update_post_meta after form is submited
- Add custom fields after post/page title
- Do something when user creates post (that’s pending)
- Why don’t some template tags work when querying information on single.php?
- Display post_meta-by_key on product catalogue
- new to javascript – using in instead of functions.php, not loading correctly
- How to save custom made object in an array in a post meta field
- add variable to actions/functions across different files (woocommerce)
- Adding and updating repeating custom field meta data
- wp_head not injecting css
- HELP: Code To Check Status And Write Debug Entry
- delete_term is not working properly with add_action()
- How to get variable from other function inside class function using add_action for Ajax call
- Function attached to cron job not running but will run if called manually
- Submit CF7 form programmatically with WP-Cron?
- disable a specefic sidebar when user is log out
- wp_update_post breaks my function
- is there a list of actions on WordPress
- Remove Actions/Filters added via Anonymous Functions