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?
- Issues with title-tag and document_title_parts
- How to hook a filter to catch get_post_meta when alternate a custom field output?
- How to use update_{$meta_type}_metadata filter to modify meta value
- How to pass/get data to/from the WooCommerce data-product_variations object?
- How to check if a hook is hooked or not?
- Remove description from on Home
- 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
- How to hook wp_list_pages?
- Don’t replace “|” with Empty String (“”) when generating slugs from title
- How to make post and comment count unclickable with dashboard_glance_items hook
- How to use the_excerpt in a filter hook?
- Hook into admin post list page
- How to limit the pages displayed for choosing parent page on page attribute’s menu?
- How can I hide all posts that don’t have a thumbnail?
- Changing document title only on a custom page template
- Filtering ‘the_title’ with option to return subhead?
- How can I reliably and globally disable wptexturize?
- Customise Jetpack Publicize text
- Setting title using wp_title filter
- WordPress RSS feed – filter RSS content by custom field value
- filter the_title problem in nav
- Filter the URL of next_posts_link & previous_posts_link
- How to replace any occurence of Gravatars with a local placeholder image?
- How to filter into post meta data before saving
- Sensei LMS Hooks to Remove Content
- What hook/filter can I use to add/edit/show/hide the title under (on hover) links on the table view?
- Change WordPress RSS link with filter?
- Explanation for remove_filter used in the below code [closed]
- Add a header before fields added with the attachment_fields_to_edit() filter
- Hide content editor for posts after approriate date
- Gutenberg disable the “block” tab in right sidebar
- How to remove get_post_metadata using remove_filter inside a class?
- Why my admin doesn’t work after adding rest_prepare_post filter?
- When to use actions and when to use filters
- add_filter to ‘woocommerce_before_main_content’ [closed]
- Editing
- Same Conditionals Not Working on Two Different Hooks
- Filter or Hook to catch pre-rendering of post content
- Sorting and limitation with pre_get_posts
- check to see if hook is available
- Variables in post title
- apply_filters/do_action tag characters limit
- How do I target a single page to modify the comment form of only that page?
- How do I hide the current page’s title?
- How to removes all instances of thumbnails displayed in my theme?
- Insert term when page is published – avoid duplicates after edits
- When does a function assigned to the content_filtered_edit_pre filter hook fire?
- Capture post content before page renders
- Remove_action does not work
- Don’t see add_filter result in the site front page
- Add content as soon starts
- Access get_the_title() from ‘excerpt_length’ filter
- Make an array filterable per hook
- How do I add a checkmark to my-sites save settings hook
- Comment search plugin
- How to filter backend post list showing only posts having a shortcode
- Add Lightbox To WordPress Native Gallery
- How can I replace an oEmbed URL in post with actual embed HTML
- Woocommerce “added to cart” message on main(home) page
- 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?
- filter hook to load a different post/page on current post/page
- 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
- How to filter page title for certain page?
- 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
- Can you call a filter hook by “add_action”?