There are several ways to achieve this, none of them elegant. That’s because there is no general way to know exactly where get_the_title
was called.
(1) Not completely foolproof, but possibly enough in your scenario would be to add is_main_query
to your conditions. That would rule out titles generated in secondary loops. However, if the breadcrumb is generated inside the loop, this would obviously not work.
(2) You could use debug_backtrace
to find which template file called get_the_title
and add this being single.php
as a condition. Assuming the theme uses such a template. Also assuming there is no secondary loop in this template.
(3) You could skip the filter on the server side and convert your code to a piece of javascript that detects the presence of a certain class and insert the html
on the user end.
Related Posts:
- How to get page’s ID if I know the title only?
- Multiple Conditions for Child Page Title
- How to sanitize post title with commas
- change title separator
- Blog Title not showing up on main Blog page
- Replace text in the Title
- How come I get internal server error even with try catch for get_the_title in functions.php?
- Print title page in header of a specific page
- Show post title words one by one [closed]
- Generate page title tag from the content of H1
- Two title tags in my header
- How can I add title attributes to next and previous post link functions?
- order by second word in title?
- How to add subscript and superscript in WordPress page titles
- the_title filter applying to menu items
- Fill post titles from post content?
- Empty title on front page/Home
- Changing “Enter title here” based on post format
- WordPress i18n-friendly preg_replace post title
- How to set custom title of custom page template?
- Display post title on individual image attachment page
- Include category title in wp_title
- Get wp_title() from page ID into a variable
- Custom Post Type Title Placeholder [duplicate]
- Site title not showing. What can I do?
- posts order by title second word
- SEO meta description and title tag Yoast SEO
- What code do you use to generate the text to go into the HTML title tag?
- How come my first blog post and my home page have the same title?
- How to intercept Post Title on Post-Save
- Where do I change the ACTUAL title tag that is set in the header.php
- Why doesn’t YoastSEO allow me to set the title/description for the home page? [closed]
- Hide price & title in store thumbnail dispay? [closed]
- Add anchor text to php
- How to echo a different title to the page if it’s opened on an android mobile phone
- Remove post title
- Set max title length – similar to excerpt length for outside of single.php
- Automatically add words if duplicate post titles
- Remove Title of youtube video
- How to insert icon in site title
- How to add H4 tag to the_content filter (after content)?
- How can I automatically insert the page content as the title?
- HeadSpace2 double title on homepage
- Changing title & add Breadcrumbs
- Page title is showing category name as well in the google search results
- How to Change The Title in WordPress For SEO
- Modify conditional titles to include parent and page number
- Why is a category/ tag name prefixed to title of every page?
- Cannot use ‘CSS’ in post title
- Wrap the_title_attribute in a H2 within a Conditional Tag?
- How to echo all the_title() without text after last “-“
- set title attribute in wp_get_attachment_image()
- get_the_title outputs title until spacing; it does not get full length of title
- Permalink and ACF field
- Remove tagline from the HTML on the home page without plugin?
- Homepage meta title and description not showing in search engines?
- Double bar “|” in title (By WP SEO Yoast?) [closed]
- Prefix the title tag, if IP address is the dev server
- How to put post title or keyphrase in content on different places automatically?
- Change meta data of pdf file
- How can I add a title to this ‘maintenance mode’ function?
- Modify link options when hovering over post title
- Change auto post title generation according to different post properties
- How to get Title of Home Page to Appear on Page
- Need help with page title (Static front page)
- Strip $before & $after strings from a page title
- Text under post title on frontpage but don’t want it in full post
- How do I remove ‘Home’ from homepage title?
- Inconsistent title for posts
- Title don’t function as link
- How to add a span class in the post title?
- Adding a class to post title considering the title length
- SEO module to change tag title for different listing page
- Hide a page title in WordPress 3.0
- Change post title but not in widgets/menu/etc
- how to add dynamic text before and after of post title
- Changing Title Tag on Shop Archive Page (current solution reverting to Title of First Product in Loop)
- Special characters in post_title replaced by ‘?’
- Title tag on home using front-page template not showing
- Display text if title in archive has specific word
- Post title not displaying as recorded in the wp_posts table
- How do you change the title of the Edit Post page?
- Page Title Dependant On Input?
- Reorder title tag and description tag with wpseo_title and wpseo_metadesc
- Blog Post Title apearing twice
- How do I separate the post title from the content in an excerpt coded thus:
- What change does this code need to include title of parent?
- Comparing pre-saved post_title to post-saved post_title
- Different titles for static, posts, and every xy page
- The entity “raquo” was referenced, but not declared
- How to get the meta title of a page configured as blog (loop)
- Add Placeholder in WordPress Editor Content Box
- How to get all post titles starting with numbers and symbols?
- My post titles is getting mashed up with my blog title
- What is the wordpress page title php code?
- How can I change tagline in title tag “Just another wordpress site”?
- Rename file after title , one small problem
- I have a problem with Home Page title
- Title displaying multiple times
- How to fix special characters when the title or excerpt is shortened [closed]