the_title()
calls your function again. If you want to avoid that, remove the callback inside of your function:
function filter_title_after() {
remove_filter( current_filter(), __FUNCTION__ );
// the rest of your code.
But you shouldn’t call the_title()
in your function at all: it prints the title – this is not what you want – and you get the original title and ID already as an argument from WordPress. Use it.
Also, testing for POST requests should be done by checking $_SERVER[ 'REQUEST_METHOD' ]
.
function filter_title_after( $title, $post_id ) {
if ( ! is_singular() )
return $title;
if ( 58 !== (int) $post_id )
return $title;
if ( 'POST' !== $_SERVER[ 'REQUEST_METHOD' ] )
return $title;
return "Congratulation";
}
add_filter( 'the_title', 'filter_title_after', 10, 2 );
Related Posts:
- Filter the blog title displayed in the header
- Filter get_the_title to remove certain characters?
- Remove the first 5 characters of the_title and orderby that
- Change page title from page using php via php executed from page/post itself
- How to display custom seo title before the loop?
- Custom field in title
- Unique icons next to each WordPress menu item
- Display custom post type title as text if post thumbnail is not available
- Change tinyMCE editor to allow marked content when pasting from Word
- fatal error call to undefined function get_header in index.php on line 1
- Problem with login form
- Getting error when using wp_insert_post()
- Fatal Errors on pluggable.php
- Alter required message using comment form api
- How to debug this search & replace strings snippet?
- Hide Featured Image Meta Box on Editor Screen
- Add item to top of menu using a filter in functions.php
- Add filter multiple times using only one master function
- How to edit php code in WordPress Post file?
- How to make modifications only to certain elements of an HTML string on the server-side?
- Override a function defined in wp-includes/comment-template.php
- Reduce size of responsive title
- Filtering a function’ output for a new continued function
- Run str_replace on title and save the output to a custom field
- Syntax error in a shortcode function
- Deleting Certain terms from appearing on the front end as links
- Content filter won’t work
- Echo title attribute php
- Warning: in_array() null given in PHP function
- Upload multiple files in randomly generated folder using wp_upload_bits
- Create page template via functions.php?
- Add meta tags to a custom header
- Ajax filter button display all posts
- How to append to an array and return the results in a filter?
- How to have different site identity logos on each page on Astra Theme [closed]
- change title page on search result
- How do I create a secondary version of the_content
- woocommerce related product title length
- Get the_content surrounded by instead of
- Custom query vars filters problem with pagination
- Filter by field with array value in ACF on WP REST API
- wrap a span tag around author’s post count
- Get the name of menu item with wp_nav_menu
- Fatal errors to undefined function in theme 404.php file [closed]
- Split site title and apply different classes
- Displaying content on posts page based on category
- update_post_meta() not saving data inside of save-post filter
- PHP Helper Class to create shortcodes
- How to add aria role and schema markup to custom walker container
- Can I remove or edit an include() from a function with a filter?
- Dynamically adding filters
- Must filter functions receive all arguments passed to them?
- wordpress admin part is not accesbile after server shifting
- WordPress doesn’t load HTML
- Insert content into head tag with function
- How do I choose not to display the title header on a specific page?
- How to internationalize header image?
- apply_filters with several different values?
- How can I modify this code to make the search box include tags and meta
- User filter posts by year
- How to add a custom filter (by coding) before access one wordpress page ? And where to call the custom filter?
- How to sort WooCommerce products page by latest in-stock items first?
- Set document title through shortcode plugin
- Error while loading wordpress site “Fatal error: Uncaught Error: Call to undefined function twentytwentyone_the_html_classes() in /home
- How do I make these combination select filters work when only one dropdown is set? They work in WordPress 5.8.2 but don’t in 5.8.3
- Show related products by attribute based and certain conditions
- How to Create custom block for displaying information in content section which act like shortcode
- Filter wordpress posts without searching the keywords in the post content
- Variation prices breakdown only for single product page
- Test the existence of a page/article by its URL, taking in consideration the URL rewriting by filters
- Filter ‘comment_notification_text’ not working
- Remove Author Links
- how to replace h1 entry title with h2 in category pages only
- How to run php code only for a specific widget on a page and not all widgets on that page?
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- Connecting to upstream failed
- Posts title instead of Pages and Category titles – PHP WordPress
- Apply function.php filter only if url not has /amp/
- Change the “Show All” button in a WordPress Portfolio Filter
- Fatal error: wp-settings.php on line 199
- How to use apply_filters() inside a plugin class?
- Change lost password url to a mailto URL in WordPress
- Shortcodes not processing inside post content
- Remove span tags from WooCommerce Downloads page
- Time Stamp In A WordPress Post Title That Does Not Keep Refreshing
- How to edit post meta data before publishing the post it self wordpress?
- Multiple Tag Filtering
- Add a top bar to a wordpress theme without editing the header.php file?
- Reduce Stock Based on Custom Variation Field Rather than Attribute (Working Script)
- I want to hide “sold by” on certain pages with id page 43
- Fatal error: Uncaught Error: Class ‘WP_Block_Styles_Registry’
- Should I set a page as “No-index” if I include it’s content within the front-Page.php via this method?
- using filter and hook inside class
- How to bind each “the_content” elements to a custom variables
- How can I get the custom post title?
- How to change href of a Widget menu item link?
- Reload page with a different shortcode when a user selects from a dropdown
- Filter portforlio with librairie isotop
- WordPress Ajax filter: Create two loops for different output styles?
- Site title not showing. Please help me