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?
- WordPress hooks/filters insert before content or after title
- How do filters and hooks really work in PHP
- Trouble understanding apply_filters()
- 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 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
- How to pass/get data to/from the WooCommerce data-product_variations object?
- Where to hook into post content?
- 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?
- Remove description from on Home
- Passing Additional Parameters to add_filter Callable
- What hook do I use to edit the post statuses option in admin?
- Filter hook before create order WooCommerce
- Modify WordPress Rest Api Request/Response
- How to add some custom HTML into wordpress admin bar?
- Custom theme hooks / filters – passing arguments
- wp_mail – Remove sitename from email subject
- Remove “Private” + “:” in title does not work
- Filter Widget Title Wrap
- How to disable all WordPress emails modularly and programatically?
- How to hook wp_list_pages?
- apply_filters() slices away needed arguments
- Don’t replace “|” with Empty String (“”) when generating slugs from title
- WP Rest API – Upload media without saving attachment post
- How to make post and comment count unclickable with dashboard_glance_items hook
- How to use the_excerpt in a filter hook?
- How to add attribute to output with wp_video_shortcode add_filter
- How to change Woocommerce breadcrumbs content?
- 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?
- How can I display image metadata?
- Add an attribute to the root from functions.php with add_filter
- Would like to use hook or filters to customize email templates
- Hook to add content after date in post?
- Is it possible to assign a css id to a row in plugins list table?
- Right filter for rewriting page statuscode
- Add filter return false not working
- How to filter page title for certain page?
- Add Index to Item in WordPress Gallery
- Remove image of srcset
- Re-order search results with posts_orderby filter and post meta value
- 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
- Adding Filter | Page Title | Template | Why the_title affecting on menu?
- How to filter wp_get_recent_posts() to only posts that have thumbnails?
- Hook inside a hook
- Incrementing content with extra text after save/publish
- Adding user filter – Not updating data in URL
- wp_editor customization
- How to check which submission button was clicked?
- Converting restricted html in comments to bbcode
- Why none of xmlrpc filters work
- How to add more than one custom metadata as filter on the post list page?
- WP Dashboard -> Posts-> Filter by Category -> Form Method Change : Which Hook
- change attachment custom field onChange event
- How to add a class to Buddypress avatars in the Activity stream? [closed]
- Admin filter/error if post title is too long
- Add class to all parent elements inside the_content
- Adding an orderby filter, casting postmeta with multiple keys
- Which hook should be used in this case?
- Filter dashboard custom post listing by user
- Getting entry ID from frm_email_message filter in formidable
- WooCommerce comments_template Filter Not Firing
- Admin New Order: Autofocus on Search a product
- NextGEN Gallery: Adding drop-down menu widget to gallery view without modifying plugin code [closed]
- How to filter part of a variable if it is no array?
- str_replace css meta tag?
- How do you disable the verification process of user email changes?
- How to use apply_filters(‘get_calendar’) to change get_calendar() output?
- Can you call a filter hook by “add_action”?
- Better way to change the default password reset url with the woocommerce one?
- Hooking/Filtering theme name to add theme directory
- How to elect position of new item output in a dropdown when using add_filter
- Replacing text using add_filter
- Passing value from one hook to another
- Change password reqts with NO plugin without breaking resetpass link?
- How to Dynamically Switch WordPress Front Page Without Causing Canonical Redirect?
- hook on the_excerpt
- Why wordpress doesn’t allow to add author filter to media library page in grid mode
- “Invalid parameter(s): attributes” issue in context of “blocks.registerBlockType” filter
- Adding custom filter not working
- Core/Image access caption in render_template and in wp.hooks
- Ship block templates or block template parts with plugins
- How to add custom field to top of WordPress Comment Form for both logged in and anon users