[wp-trac] [WordPress Trac] #34513: is_single() or is_singular() are not running filters on the queried object
WordPress Trac
noreply at wordpress.org
Fri Oct 30 20:48:55 UTC 2015
#34513: is_single() or is_singular() are not running filters on the queried object
--------------------------+-----------------------------
Reporter: LindsayBSC | Owner:
Type: defect (bug) | Status: new
Priority: normal | Milestone: Awaiting Review
Component: Query | Version: 4.3.1
Severity: normal | Keywords:
Focuses: |
--------------------------+-----------------------------
I ran a basic piece of code that was meant to do the following:
If the page I am looking at is the single post for a specific post type
(events), append an anchor tag and some text to the title.
I did this by using the_title filter and the is_singular() conditional.
According to the codex for is_singular() and is_single it says that it
will only run the code on the queried object (the single post for the
specific post type loop).
'''Expected Results: '''
I expected to see my new content appended to the title of the post that
was in that specific post type
'''Unexpected Results:'''
I saw my new content appended to every single item that was in a WP loop
including menu items. This only happens on the single view of the post,
however. So if you go to domain.com/events/a-single-post you would see my
appended anchor tag all over the place. If you got to the single view for
any other post type, however, you do not see this.
'''What this tells me:'''
This tells me that there is something wrong with those two conditionals
where they are actually working, but they are not returning the proper
post data. I have not yet looked into the source of those two functions so
I can not say more than that.
Here is a gist of my code. This has been tested on a vanilla WP install
and confirmed
https://gist.github.com/Lindsayanng/5b18ace5b2427f72c307
Screenshot attached so you can see what I was seeing.
--
Ticket URL: <https://core.trac.wordpress.org/ticket/34513>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list