Depending on the way your theme uses the_title, hooking into the the_title filter may or may not hide the title h1. What theme are you using?
The the_title filter passes two arguments: the title (string) and the post ID. Therefore, treating the title as an array (it looks like you’re assuming $title is an array of post data, trying to set $title['post_title']. To have the_title return an empty string if the custom field “hide_title” is not empty, the following would suffice:
add_filter( 'the_title', 'wpse145940_hide_hidden_title', 10, 2 );
function wpse145940_hide_hidden_title( $title, $postid ) {
if ( get_post_meta( $postid, 'hide_title', true ) ) {
$title="";
}
return $title;
}
Related Posts:
- WP action/filter to modify title before header output and article output?
- Modify WordPress Page Title ()
- Anyway to edit the titlebar of WordPress Widgets in the Admin area?
- Strip $before & $after strings from a page title
- Filter the title to only affect the_title() template function
- get_the_archive_title hook unwanted changes!
- Auto append text after the title?
- How many filter/action hooks are healthy?
- How to use update_{$meta_type}_metadata filter to modify meta value
- Filter specific shortcode output?
- Earliest hook to reliably get $post/$posts
- What does (10, 2) mean when used with add_filter
- Clarification on filters and hooks
- Valid characters for actions, hooks and filters
- How to hook into unregistering a widget instance?
- How to check if a hook is hooked or not?
- Passing Additional Parameters to add_filter Callable
- Modify WordPress Rest Api Request/Response
- How to add some custom HTML into wordpress admin bar?
- Custom theme hooks / filters – passing arguments
- Remove “Private” + “:” in title does not work
- How to disable all WordPress emails modularly and programatically?
- How to hook wp_list_pages?
- Don’t replace “|” with Empty String (“”) when generating slugs from title
- How to use the_excerpt in a filter hook?
- Hook into admin post list page
- Alter only the page title, not the post titles within
- Change text of Description in Image Library
- Load different template file when condition met?
- Am I using the right hook for removing quicktags on the admin TinyMCE?
- About Hooks and Filters
- Changing document title only on a custom page template
- Should I use add_action(‘publish_post or add_filter(‘publish_post?
- Filter all html output
- Add a Span Around a Product Title in WooCommerce [closed]
- Too many actions/filters!
- How to get list of all hooks of current theme / plugin?
- Which hook is fired when inserting media into a post
- How to filter into post meta data before saving
- Change WordPress RSS link with filter?
- Filter list by a unique meta value dilemma
- How to remove get_post_metadata using remove_filter inside a class?
- add_filter() function misunderstanding
- Is it possible to track down Actions and Filters?
- Filter get_the_title to remove certain characters?
- get_title without filter(the_title)
- Filter or Hook to catch pre-rendering of post content
- Sorting and limitation with pre_get_posts
- Can the wp_filter object hold multiple values with the same key
- check to see if hook is available
- apply_filters/do_action tag characters limit
- How do I hide the current page’s title?
- How to modify core when there is no hook?
- Post Content, Special Characters and Filters
- How to filter for user registration, be able to throw error message
- How to remove action with slashes and arrows?
- Better extend a class or use add filter/action hooks?
- Add content as soon starts
- Access get_the_title() from ‘excerpt_length’ filter
- Changing WordPress core without hacking core
- Customize title, description and focused keyword [closed]
- Comment search plugin
- Plugin options, presets and filters : can you help me improve my workflow?
- how to customize rss feed tags using hooks?
- Filtering the post list in the admin area
- How can I replace an oEmbed URL in post with actual embed HTML
- Detect when gutenberg editor title is available in Dom after editor load
- Is it possible to bind a function to a filter hook via Ajax?
- How do I hook my function to run only after submitting login form
- Prepending character(s) to a custom tag title?
- Modify existing plugin function with add_filter
- Filter posts by meta data using custom query
- Remove tags without a specific meta key from “choose from the most used tags”
- What is the action hook to use if you want to capture the new password during password change?
- How can I edit comment meta value before it is saved?
- an action hook when a post reaches a certain number of views
- Action hook to control access to certain parts of my site
- Need to return shortcode text instead of the output
- Excluding posts by meta, and also keeping posts without the meta
- Where exactly does the edit_{taxonomy} hook fire?
- Is there any reason for the nested filters to be applied on the first case and not in the second one?
- Replace Data In Post & Update Meta Field Post Is Saved
- Filter Media by attached page or blog post in Library
- How to add custom media library mime icons?
- Add filter return false not working
- Security question – Display a General Custom Login Error Message
- Filter wp_mail based on content type
- Add HTML to the bottom of each post in a post list
- Hook inside a hook
- Incrementing content with extra text after save/publish
- WP Dashboard -> Posts-> Filter by Category -> Form Method Change : Which Hook
- Add class to all parent elements inside the_content
- Adding an orderby filter, casting postmeta with multiple keys
- Getting entry ID from frm_email_message filter in formidable
- Better way to change the default password reset url with the woocommerce one?
- Hooking/Filtering theme name to add theme directory
- Replacing text using add_filter
- Passing value from one hook to another
- Change password reqts with NO plugin without breaking resetpass link?
- How to add custom field to top of WordPress Comment Form for both logged in and anon users