You should use filter not action:
function adddd( $title, $post_id ) {
if( in_category( 30 ) ) {
$title="Prefix - " . $title . ' - xxx';
}
return $title;
}
add_filter( 'the_title', 'adddd', 10, 2 );
Related Posts:
- Add Category name to Post Title (h1)
- I want to show category in the post title , how can I do
- How do I include the category next to the title of a post?
- How to select a category automatically based on a word in WordPress post title?
- Create/Set Category as Title of Post
- Post Category link is same with Page link
- Is it possible to have different header style blog titles in different categories?
- Apply the_title() filter in post & page title, but not in menu title
- Different post sort order within different categories
- How to add metabox for post of specific category
- Manipulate post category after time
- Dynamically update post title in admin page
- Categories box not showing on post edit pages
- List only child categories a post is in, of a specific parent category
- Add custom field to all posts in specific category
- Exclude category on blog list page
- is there a better way of combining this?
- wp_list_categories link to first post of category instead of calling taxonomy template
- Displaying Page Title on index.php
- How to Add ‘Post Categories’ to the Dashboard Sidebar
- How only display all post related to category
- How to add a custom field after wp post
- Add category to all post by using sql query?
- Display posts in alphabetical order for a particular category
- How to prevent WordPress from updating the modified time?
- Full Width Main Post
- Direct link to “New post” in specific category?
- Using permalinks, category slugs, and tag slugs
- How do I retrieve then print the currently viewed sub categories?
- Pulling in post category and children within category
- Post categories to pages
- WP_Query: Mixing category__in and tag__in together
- If in_category not working for multiple single.php pages
- Set Default Category to Username
- Listing Specific Categories from Current Post with Depth
- Display post category in foreach loop
- Single.php – Get Current Parent Category
- get_the_category listing in hierarchial order
- How show categories in admin and get that selected to show posts in index
- Create a list of posts with topic headdings
- if in category but only with post meta
- singular posts using archive styling
- Show posts on front page only
- Get featured image on hover of post title [closed]
- How do I display the post_title with get_permalink?
- Post is in descendant category not working in home.php
- How to get posts ordered by using their categories?
- Hide parts of the post content after typing it’s name or searching it by category
- SQL Bulk Move old posts by one author to another category
- load more posts by category
- Display Related Posts by Category in Random
- Getting posts from some categories plus some individual posts
- Change layout of post depending on category
- How to show beneath posts the full category path?
- Display Current Posts Category (with the most posts)?
- Allow / show post comments in category pages
- Only the most recent post is showing on my category page (working on localhost, not live site)
- Adding Text after Post Title based on Category using IF Condition – But not for menu items
- Display default matabox of posts(add category) wordpress
- How display related post only in Default category on single
- How to merge the content of posts that have the same title?
- ACF date picker to trigger category change
- Get category slug of the Parent category of a Product
- How to get tags when using publish_post
- exclude particular category in api
- How do you change the permalink for posts for a single category?
- Make categories appear random
- how to create a category with wp_insert_post and post_category
- How to add a block to a category page?
- How to make a page show posts only from specific categories without editing php files
- Get posts from category from custom query
- My posts page is missing the page title
- How to show posts ordered by random [duplicate]
- How to Get Position of a Post from a category and tag
- Display new posts categories in separated divs
- Add Categories To Custom Post
- Query posts from newest category
- Precedence of page permalinks over woocommerce product category links?
- Display Posts by Categories
- Ajax – Post Categories and Load More
- Edit Posts Page but not category specific pages?
- Add category selection to function request
- Show Post number of specific Category
- prevent same wordpress post title
- How to organise post by category and date
- Show post if in category
- How to display custom content in post with category XXX
- Displaying categories items among posts
- Displaying different posts Via wp_list_categories()
- Category pages vs single post pages
- How to display subcategory articles in the category view?
- Display ONLY Latest Post From Several Categories
- Show all posts in category
- Polylang – display one post into 3 categories with different lang [closed]
- Export Posts Without Categories In An XML File
- Sort Posts Alphabetically Based on Specific Category (Divi)
- How to link Post Title to uploaded file?
- I have a blog and want to prompt the user to select a category they like and have that select a random blog post
- I have a website issue I am trying to resolve
- How to sort posts alphabetically based on a specific parent category