#47096 closed defect (bug) (worksforme)
get_post_type() in author.php return random post type
Reported by: | wolly | Owned by: | |
---|---|---|---|
Milestone: | Priority: | normal | |
Severity: | normal | Version: | |
Component: | Posts, Post Types | Keywords: | |
Focuses: | Cc: |
Description
I have created an author.php page.
I have a do_action in sidebar
When I add_action I check if it's a given post type, before adding action.
But in author.php get_post_type() return a CPT, different on different server, maybe it's the last registred.
Change History (4)
#2
@
6 years ago
In the sidebar I have a function that check what cpt is.
Based on that check, I add action or not.
I solved using ! is_author, but, probably is my mistake, I thought that in author php I had non CPT value.
You are sayng that it take the cpt value of the post in the loop, in this case, the first one, since the loop is of mixed post type.
If this is the expected result, it's not a bug :-)
Thanx a lot for your time
Note: See
TracTickets for help on using
tickets.
get_post_type()
returns the post type of the global$post
, which can be a different post depending on where exactly on your page you are calling it and depending on what kind of posts the author has written.Not sure what else you would expect from that function on the author archive..?