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
- WordPress Theme Update Action?
- add_action in a function, is it possible?
- Using a private method as an action callback from within a class
- How to restrict actions and filters “properly” by conditions
- 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
- How to hook into the quick edit action?
- update_post_meta for custom field not working upon form submission
- Call to undefined add_action() in theme’s functions.php
- WooCommerce add_action hook results in 500 error
- How to add iOS & fav icons to the theme?
- Convert User ID’s to User Names in a single.php file
- Trying to inject twitter metadata into using wp_head action in functions.php – get_the_excerpt() returns null
- How would go about if I just want a temporary function?
- How do I edit wp_head and/or functions.php to remove rss-feed which isnt used and dont validate?
- Pass parameters to function through an action
- Accepted arguments value in hook functions
- How to select a page within admin?
- How to manage arrays from custom functions stored in functions.php?
- How do I pass arguments for multiple functions hooked to a single action?
- Which action hook to use for function?
- Custom HTML in specific category single page and its descendant categories
- Modify a function without editing template
- Don’t delete a page if it holds users
- How do I add Bootstrap and LESS to my migrated WordPress site?
- Passing a variable via wp_head and then calling it on the page
- What WordPress function to use to get meta value by using meta keys?
- Is there an alternative to get_template_directory_uri()?
- Reuse variable in hook callback
- Wait a result before enqueue
- Default Custom Field Value Automatically Update
- Multiple Loops Meta Data
- Remove adjacent_posts_rel_link under 3.2?
- Function added using `add_action()` not being called
- Two functions with different arguments and add_actions, but identical code
- I can’t seem to install Font Awesome locally [closed]
- Prevent custom field from being updated after first publish
- Auto Generated HTML source code formatting
- User function to return multiple get_post_meta()
- Auto-Tweet if Type is ‘Status’ using OAuth
- Missing argument for the function
- problem loading stylesheets to wp_head dynamically
- How to properly refresh page after form action?
- Init action and refresh page after form action
- How can I pass a shortcode value to the head in wordpress functions.php
- Need To Change WordPress Meta Tags… Includes wordpress shortcodes
- Insert Content Before div#main from the functions.php File
- Use add_action within template
- Problem in using Customizer
- 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
- template_redirect action only firing if logged in
- How to change text color depending on the number value (Using javascript)
- 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?
- What is the earliest Hook a Script can use?
- How do I trigger WP CLI DB export using a PHP function?
- Hide author info in single posts by certain users
- post value to function with Ajax and jQuery
- How Do I Unhook This Parent Theme Function?
- blank page with wp_get_attachment
- 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
- How to change form action of wp-login page with a function
- Creating a “Related Meta” type field?
- Remove post from latest posts after a month only with certain tag
- 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?
- 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?
- Automatically add custom fields (post_meta) to all published posts, hourly, via wp_cron?
- function to return comma separated list of meta values
- update_post_meta after form is submited
- Do something when user creates post (that’s pending)
- Why don’t some template tags work when querying information on single.php?
- 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
- How to get variable from other function inside class function using add_action for Ajax call