If your theme supports WordPress adding the title tag using add_theme_support( 'title-tag' );
(it should!) you can use the document_title_parts
filter to insert the post count in the right place without needing to parse the full title or modify existing elements that might have been customised, such as the separator:
function wpse_323260_document_title_category_count( $title ) {
if ( is_category() ) {
$category = get_queried_object();
$title['title'] = sprintf(
'%d posts in %s Category',
$category->count,
esc_html( single_cat_title( '', false ) )
);
}
return $title;
}
add_filter( 'document_title_parts', 'wpse_323260_document_title_category_count' );
Related Posts:
- How to change the seperator in the title
- Change the output of wp_title()
- Html title best practices and usage (wp_title, title-tag support, etc..)?
- wp_title() shows 404 – installation outside WP
- Dynamic webpage titles
- wp_title() function in tag
- How do I fix title? [closed]
- The tags can only contain a call to wp_title(). Use the wp_title filter to modify the output
- How do I get rid of the vertical bar in the url
- How to remove a specific string from inside the tag of a WordPress Page
- How to add WordPress Settings in sidebar widgets
- How to show page title in blog post of wordpress site
- How to collect heading tag in a single post, such as Microsoft Word?
- Wrap the 2 firsts words of title with a
- Display last updated in
- Site Title and Tag Line(Both are) Show on my Meta Title/ Site Title
- Assistance with wp_title function
- how to customize the page title of a custom php file
- error in wp_title on year archive – undefined index 00
- Filtering wp_title() in WordPress
- WP Title only in lowercase letters [duplicate]
- light-wrapper page-title
- Limit the word count in the post title
- Changing title of a page dynamically from within a plugin
- REQUIRED: The theme must not used the tags. | REQUIRED: The theme must not call to wp_title()
- How to set custom title of custom page template?
- Include category title in wp_title
- Add specific word before the category page title
- WordPress page title repeated in SOME pages
- Get wp_title() from page ID into a variable
- Displaying Page Title on index.php
- How can i remove JUST the title tag from wp_head() function?
- How to list all titles of posts on a specific page?
- why adds ‘»’ symbol?
- Search query – exact post title match
- Custom WP TItle from custom template with dynamic URL structure
- Replace category titles
- How to change the page title from functions.php
- Change all Post titles into [Title Case] format
- How to modify a title tag in genesis?
- Can not set custom title on some WordPress setups
- Page title not showing up
- An extra ‘ is displayed in the title
- Woocommerce: How to remove page title from storefront theme homepage
- Events Made Easy Plugin – Duplicate Title Tags
- Get wp_title wp ajax
- wp_title() returns ‘page not found’ on page 2
- How to Change The Title in WordPress For SEO
- How to remove main domain header title from after sub domain header title
- change title separator
- Change page title dynamically before header is rendered
- Why is a category/ tag name prefixed to title of every page?
- Where does Yoast SEO plugin sets the site/page title?
- After I set the title, it over-wrote all the titles for the individual pages
- Replace text in the Title
- Keep Title and Description always
- Automated Footer information
- Title tags show twice
- How to solve the site tag being displayed twice?
- Theme support title tag – how to replace the default WP separator (with a filter)?
- post_exists returning 0 if title contain special characters
- disallow publish posts with special title
- Remove dash from blog title wordpress
- How to set page title tag in custom template for non-Custom Post Type?
- Modify page title and subtitle with a plugin
- Set title of page using custom page template
- Order by title – but now built in wordpress func, sort the_title
- How to customize a title by passing query string?
- Why doesn’t this function work when I know that the IP Address is “true”?
- WordPress Body Content How to add current page title automatically in different places?
- How to Customize Wp Default Title and a prefix
- How to get string from add_theme_support(‘title-tag’) for meta tag and beautify?
- How to change dynamically page title according to variable data?
- How to add custom filed value after in wp post title
- How to place POST TITLE any location inside the posts page
- add_theme_support( ‘title_tag’ ) is not showing title on index.php
- Split post title for styling
- What could be causing the category to be appearing as the post title in the title tag?
- Add PHP code after title in single post pages?
- Modifying WP_Title For Custom Post Type
- Need help with page title (Static front page)
- Remove Site Name from wp_title WITHOUT removing from attribute
- When trying to set title, not sure how to edit it for different pages
- Page Title repeating
- How to add first 3-4 post tags on WordPress Post Title
- Modify WordPress Page Title ()
- Title tag on home using front-page template not showing
- Trying to add some custom text into WordPress Post title via function.php
- Post title not displaying as recorded in the wp_posts table
- How do i tweak my wp Post title base on category of the post
- Changing title using filter not working with argument
- how to get wp_query posts only first letter of alphabet A?
- long-title posts do not want published
- How to get page title () in a different order?
- Please I want to prefix my WP posts title according to each category
- Set page title in WordPress with PHP
- Reorder title tag and description tag with wpseo_title and wpseo_metadesc
- HTML regex convert to titlecase
- tweaking the
- I have dynamic title tag in my wordpress but seo analyst show “No title Tag found error”?