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]
- 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?
- 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?
- Search query – exact post title match
- 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
- 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
- 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?
- Set title of page using custom page template
- How to customize a title by passing query string?
- Why doesn’t this function work when I know that the IP Address is “true”?
- How to Customize Wp Default Title and a prefix
- How to change dynamically page title according to variable data?
- 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?
- 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
- How to add first 3-4 post tags on WordPress Post Title
- Modify WordPress Page Title ()
- Trying to add some custom text into WordPress Post title via function.php
- 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?
- How to get page title () in a different order?
- 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”?
- Hiding title of selected post without plugins
- get_the_archive_title hook unwanted changes!
- “Page Array” displaying in title bar on Front Page
- Modify title of custom taxonomy archive page
- How can I use a specific wordpress page template if certain words are used in page title [closed]
- wordpress filtering out caps in wp_title? (UpperCase is changed to Uppercase)
- my site show this symbol (::) between site title and tagline
- Site name not showing in browser bar, only url
- Display tab title as ‘blog tagline | blog title’
- double page title [duplicate]
- The title of an attachment is not working
- template_redirect and title
- Title image is missing ( but is not the WP 3.5 issue )
- How do I replace title with my plugin?
- Title displaying multiple times
- Adding a custom field after post title (ex.Example Title [30 Second Read])
- How to change twentytwelve child theme site title separator
- change title of page dynamically