Tell us what you are trying to do? I want to have a script to the header <script> window.abkw = 'YOUR_KEYWORD'; </script> and I want to replace the 'YOUR_KEYWORD' with a custom-field data... Firstly please advise Toolset allows to add scripts into the head section or if not, could such a script work well in the body as well?.. I might have other script to add too.. and mainly could I add a unique facebook pixel to each of my posts?
Is there any documentation that you are following?
Is there a similar example that we can see?
What is the link to your site?hidden link
Hello,
How do you display the <script> window.abkw = 'YOUR_KEYWORD'; </script> in the HTML header?
If it is custom PHP codes, you can use Types API function types_render_field() to render the custom field values, see our document:
https://toolset.com/documentation/customizing-sites-using-php/functions/
And you can follow WP document to add the custom JS codes:
https://developer.wordpress.org/reference/hooks/wp_head/
Hi Luo Yang
The reason I need that script is because it carried a keyword for the POST .. it's for the adbutler which is an ad serving platform.. they have a plugin that adds a field to every post we have on wordpress.. How can I make this field available to a custom post?
Please advise.
Regards,
Alim
Hi Luo Yang
The reason I need that script is because it carried a keyword for the POST .. it's for the adbutler which is an ad serving platform.. they have a plugin that adds a field to every post we have on wordpress.. How can I make this field available to a custom post?
Please check screenshot.. at the bottom left you will see the Ad Butler field.. I'd like to have this in my custom post too.. that would solve my issue for adding the keyword to the post...
Please advise.
Regards,
Alim
Thanks for the details, I assume we are talking about the plugin download from:
https://wordpress.org/plugins/adbutler/
This plugin is using a custom field "abkw-text" to store the keyword value, and the keyword input box does not support shortcode:
https://toolset.com/wp-content/uploads/2020/05/1639883-Screenshot_2020_05_27_19.25.07_2.png
There is a workaround, you can use WP built-in filter hook to change the keyword to a custom field, for example, there is a custom single line field "test-s2" in your website, you can add below PHP codes into your theme file "functions.php":
add_filter( 'get_post_metadata', function($metadata, $object_id, $meta_key, $single){
if($meta_key=='abkw-text' && isset($meta_key)) {
$metadata = get_post_meta(get_the_ID(), 'wpcf-test-s2', true);
}
return $metadata;
}, 100, 4 );
Please replace "test-s2" with your custom field slug.
More help:
https://developer.wordpress.org/reference/hooks/get_meta_type_metadata/
Hi Luo Yang
Thanks for the update.. and this could work for me but the easier option for me would be, as I asked you in the earlier message, to have the ad butler keyword field in my custom post - edit view...
The way the Ad Butler field appears in POSTs, how do I enable that my Custom Post also shows this field?
Regards,
Alim
For the new question, I assume we are talking about this:
There is a custom post type "my-cpt" in your website, when you edit a "my-cpt" post, you are going to display the input box of "AdButler Keyword".
Can you confirm it?
If it is, there isn't such kind of feature within Toolset plugins, it depends on the plugin "AdButler", I suggest you check it with the plugin author of "AdButler":
https://wordpress.org/support/plugin/adbutler/
check if it supports custom post type.
Toolset Types plugin is using standard WP function register_post_type () to create new post type:
https://codex.wordpress.org/Function_Reference/register_post_type
My issue is resolved now. Thank you!
I have created a Support Ticket with Ad Butler as you had suggested. Hope I have a solution for this from them.
Thanks again.. Have a nice day..:-)..
Regards,
Alim