The first thing that i am not getting is $exclusive->y ? can you please share custom field settings that you have created?
And the second thing that i have found, you must have to put global $post; in the first line of the function :
add_filter( 'the_title', 'wpb_new_title', 10, 2 );
function wpb_new_title( $title, $id ) {
global $post;
if('post' == get_post_type($id)){
$exclusive = get_field('exclusive', $id); // pass the id into get_field
$title = $title .', ' . $exclusive;
}
return $title;
}
I have added a title on the default post. see the screenshot of the settings and the view page.
in viewpage my post name is Hello World and i am adding “,test additional title” from the filter hook.
Please check, If it works for you. also please share the details that i have mentioned.
Thanks!:)
Related Posts:
- How to reference PHP in Javascript
- How to call a PHP function from Javascript in WordPress
- How to store the_title() into a variable to reutrn the value, not just echo it
- How do I make my function add variables/values to the $post object?
- WordPress Infinite Scroll without using any plugin
- How to preserve PHP modifications while upgrading WordPress?
- Calling a method from functions.php on a click of a button
- How to use WordPress (PHP) functions in AngularJS partials files?
- Cleanest/Fastest way to avoid calling and retrieving data from the database multiple times?
- Understanding WordPress child theme custom JS loading
- How do I know what variables are passed in a filter/action and what their meaning is?
- Click loads template via ajax
- javaScript in section of WP API
- How to speed up admin-ajax.php in wordpress
- Adding tawk.to code just before body tag on functions.php file
- How do I fetch all comments per post via WP REST API?
- Slide in Panel WordPress Post
- Pass PHP variable to JavaScript without inline JS
- Count the number of times the search form template gets included on a page
- Putting PHP variables into javascript [duplicate]
- How do I display a user’s previous orders as a select box option on a product?
- Trigger popup in a php if/else statement
- Use menu link or onClick to set a variable
- How to put a variable in a instance in the widget
- Populate dropdown with Child Pages based on Parent Page chosen
- remove wp floating submenu in wp dashboard
- Get value from shortcode to do something
- How to complete two other input fields, completed the first
- JS file work only in index page
- dynamic dependent select dropdown
- Ajax load more button for comments wordpress
- Noscript not working as it should in wordpress site
- Tell WP register script to load a script only when the entire page is loaded
- Creating WordPress Shortcode with Variable
- Why i can’t get custom fields value or post ID via Ajax?
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- Overide Variable in Child Theme
- PHP variables in a post?
- Time Delay a URL Redirect for Specific Page
- WordPress User Meta value variable into Google Gauge Chart
- How to send a php var to jQuery Ajax call with two different file
- Unable to display multiple parameters from url by javascript through shortcodes
- Cannot find the php_ini configuration file to find my error log to see why my code is not working
- Adding HTML Code to Replace Text in PHP
- Gutenberg block don’t save rich text content
- Custom global variable not working in function
- Best way to use variables in multiple functions?
- Update $wpdb query with AJAX
- Using Javascript On Page – Header and Footer Now Missing
- How do I fix Undefined variable using $_POST in function?
- Adding extra data to shortcode attributes and pass it to JS with wp_localize_script
- How do I make comment-reply-button with that takes to comment reply form on click
- custom post type column countdown
- How to call a function from functions.php with ajax?
- Custom Post type Ajax search results
- WordPress load javascript file if something… (after the page is loaded)
- Automatically refresh page if widget is added to page?
- wordpress all post filter by year
- Find the method which AJAX GET calls
- Display text of price (minus 20%) on every product page in a sentence.
- Pulling a variable into the wp_nav_menu function
- Where can I find the declaration of `$_wp_theme_features`?
- Help with my first Metabox helper class
- Trouble figuring out how to get my button to submit comment
- how can I make content from a plugin hidden when user is logged in? [duplicate]
- Import and use a variable in additional settings of Contact Form 7 [closed]
- How to hide .js files on wordpress website using php or wp plugins or any? [closed]
- Show Login Errors In WordPress/Elementor (Code “works”, but breaks site)
- hiddenQuestions.find is not a function
- change title of page dynamically
- Calling a function via a shortcode in javascript
- I got this error POST https://localhost/meraboilerwp/[object%20Object] 404 (Not Found)
- How to access admin menu labels and links on front-end?
- How to get default variation ID (woocommerce)
- Get check box values inside array for use in posting form data
- Custom PHP contact form issue
- I want change custom title in custom wordpress php page
- Recent post display using shortcode
- When would you use $_post instead of $post?
- Insert all post IDs in new database table
- Generating add_settings_section() calls dynamically
- page template for attachement page?
- Use is_product_category() properly
- Check if term object is in array
- enqueue multiple Google fonts with multiple weights and styles (italic)
- Highlight Current Tag in wp_tag_cloud
- How to break down importing of feeds
- Nested shortCode functions in the functions.php file
- Theme Options: If There is No Input, Don’t Display?
- Custom Logo URL | Help me print the URL of the custom logo I inserted into my theme
- Show only IF not Google bot [closed]
- How the functions in WP are called in tags
- admin-ajax.php responding with 0
- Using wp_localize_script to store the template url into a variable to use in JS
- Adding ads code between comments
- How can the plugin directory path be returned into ?
- How to check If Oembed is empty or not
- WordPress Redirect: Default Password Reset URL [duplicate]
- Add before_content and after_content to register_sidebar
- Making Quote Plugin more efficient