Home › Forums › Calendar Products › Events Calendar PRO › Display only events by a specific author, on the author template page.
- This topic has 3 replies, 2 voices, and was last updated 13 years, 1 month ago by
Jonah.
-
AuthorPosts
-
March 28, 2013 at 10:40 am #44281
Glen
ParticipantMy various authors can all create events logged in under their usernames. I want to put an upcoming events list on the author template page that knows to show only the events of the specific author that the page is referring to. Something I’d put under a heading “My upcoming events”. Each author represents a “branch” of a greater organization and so each branch can have its own upcoming events, and the “author” template page is being used as a branch homepage.
I know PHP very well, I just don’t totally know where I’d start to make this happen.
I thought about creating a category for each branch, and then just showing a category archive, but the problem is that allows various branch leaders to show their events in other branch leaders’ pages because you can select other categories.
Also, I have that in a sidebar widget, so I can’t really specify a dynamic category.
Any ideas / thoughts would be greatly appreciated.
Thanks!March 28, 2013 at 1:30 pm #44291Jonah
ParticipantHi Glen,
There’s a few ways you could do this but generally you’ll want to setup a custom query using WP_Query – here is an example to get you started: https://gist.github.com/jo-snips/4447338 – with WP_Query you can pass in any other args you want to use, like author for example. If you put the query into your author template, you’ll already have the author ID that you can pass to the query as an arg.
Does that help?
March 28, 2013 at 1:52 pm #44295Glen
ParticipantYes, totally. I thought that WP_Query was just for posts and pages.. but it seems from your code that it’s actually able to specify a different post type. I have the author information being retrieved no problem; I’m using it to populate a few other things on the page right now.. so I can just take that and extend it into the example code you provided. So, is getting the categories associated with an event the same as getting the categories associated with a post? I might still want to explore the categories idea so I can have N:1 authors to events.. meaning I have created categories that match with author names, so the author (or branch) of “northeast”, has a category of “northeast”.
So, my events list is, in psuedocode:$authorname = current_author_page_owner
get 5 closest upcoming events where any category = authorname
display those eventsIs getting the categories for a particular event pretty trivial?
Thanks for your help in this.
March 28, 2013 at 2:15 pm #44298Jonah
ParticipantYep, WP_Query can be used to query any post type (which includes posts and pages) 🙂 Yes, getting events by a certain category is easy. You use tax_query for this: https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters – the taxonomy is ‘tribe_events_cat’ and then you can use ID or slug as documented in the codex.
I hope that helps, but let me know if you have any other questions.
– Jonah
-
AuthorPosts
- The topic ‘Display only events by a specific author, on the author template page.’ is closed to new replies.
