Home › Forums › Calendar Products › Events Calendar PRO › Looking for a way to merge Event Category with Blog Category
- This topic has 11 replies, 3 voices, and was last updated 10 years, 9 months ago by
Support Droid.
-
AuthorPosts
-
January 25, 2012 at 1:07 pm #14125
Jason
ParticipantI need to figure out a way so that within a certain Blog Category all Events in a certain category are intermixed with the Blog Posts. Any idea how this can be accomplished?
January 25, 2012 at 2:36 pm #14136Jonah
ParticipantHey Jason, you’ll need to adjust your category query to include events in a specific event category. Try opening up your theme’s category.php file and adding the following code before the if(have_posts()) bit:
'tribe_events',
'tax_query'=>array(
array(
'taxonomy' => 'tribe_events_cat',
'field' => 'id',
'terms' => 4,
'operator' => 'IN'
)
)
));
?>
Where ‘terms’ contains the ID of the events category you’d like to include. Let me know whether or not that helps.
January 25, 2012 at 2:38 pm #14138Jonah
ParticipantOoops, code got messed up, try this instead:
query_posts(array(
'eventDisplay'=>'month',
'post_type'=>'tribe_events',
'tax_query'=>array(
array(
'taxonomy' => 'tribe_events_cat',
'field' => 'id',
'terms' => 4,
'operator' => 'NOT IN'
)
)
));
Make sure to wrap it in opening/closing php tags.
January 25, 2012 at 3:16 pm #14146Jason
ParticipantThanks Jonah, I won’t have a chance to delve into this and test it for a while, getting ready to go on vacation. But I appreciate you taking the time to offer some guidance.
I’m not a PHP programmer, but can typically hack, cut, copy, and paste my way around. 🙂 Wouldn’t there need to be something that specifies which Blog Category that I want the specific Event Category to be merged with?
I’m not sure if this will help provide more specific instructions, but I’m looking to Merge Event Category ID 8 with Blog Category ID 8. I’m not sure if its just coincidence that they have the ID #, or if that maybe has something to do with the fact that both Categories have the same name?
Also is there possibly a way to do this in the functions.php perhaps so I don’t have to modify any theme files.
January 25, 2012 at 9:32 pm #14166Jonah
ParticipantHey Jason,
What you’ll probably want to do is create a specific blog category template and in that throw in the code above to add in the specific events you want. Here’s information on creating specific category templates in WordPress: http://codex.wordpress.org/Category_Templates
Good luck!
January 25, 2012 at 10:56 pm #14167Jason
ParticipantThanks Jonah, blog category templates were not something I was aware of, but that looks like the right track for sure, and glad to learn about them.
From your snippet above, am I safe to assume that I need to change the “terms” value to 8, the Event Category ID that I want to merge with custom category template I need to create for Blog Category ID 8.
Thanks for your assistance, you guys are doing a great job supporting your plugin, money well spent!
January 26, 2012 at 8:49 am #14195Jonah
ParticipantHey Jason,
Yeah, you would want to put ‘8’ in for terms because event categories are actually taxonomies and the code above is executing an extra tax_query (taxonomy query) to check for that taxonomy ID.
Hope that works! If you feel up to it we’d really appreciate any shout outs on Twitter, Facebook or your blog if you have one!
Cheers,
JonahFebruary 16, 2012 at 9:03 am #15263Jason
ParticipantHi Jonah, Sorry to bring back this old thread but I’m finally getting around to attempting to get this working. In this project I’m using the Genesis Framework, which doesn’t have a category.php file.
I think what I’m needing to do here is create a category template that uses a custom loop.
I’m thinking the following tutorial is somewhat relevant to what I’m trying to do.
http://highfxmedia.com/blog/studiopress-genesis-custom-page-templates-part-2/Unfortunately, I just don’t know how to write the loop that will combine the Category ID that I want with the Event Category ID that I want, as the PHP programming is outside my current skill level.
With this additional information of my infrastructure is there any additional guidance you can provide.
February 16, 2012 at 10:46 am #15270Jonah
ParticipantHi Jason,
If you don’t know PHP very well this is going to be difficult and we’re not going to really be able to help you out much. This might help though, I found this googling around for ‘genesis modify standard loop’ (Source: http://designsbynickthegeek.com/tutorials/genesis-explained-framework-actions):
remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'child_do_loop');
function child_do_loop() {
global $query_string;$args = array ( 'cat' => -1, 'order' => 'ASC' );
$args = wp_parse_args( $query_string, $args );
genesis_custom_loop( $args );
}
You can try placing that in your functions.php file and then you’ll want to modify the arguments being passed to the query to include the ‘tribe_events’ post type and the tax_query args for your category… Something along these lines:
remove_action('genesis_loop', 'genesis_do_loop');
add_action('genesis_loop', 'child_do_loop');
function child_do_loop() {
global $query_string;$args = array ( 'post_type' => array('post','tribe_events'), 'tax_query' => array(... use the above tax_query code ...) );
$args = wp_parse_args( $query_string, $args );
genesis_custom_loop( $args );
}
You’ll probably also only want to execute this on certain pages otherwise this is going to affect the standard loop wherever it’s called (i.e. archives, search and category pages)
I hope that helps, good luck!
JonahFebruary 16, 2012 at 11:23 am #15274Jason
ParticipantThanks for the additional assistance Jonah, I’m going to take the info you have provided and see if someone on the Genesis forum can give me some additional help, if that doesn’t work out I’ll hire someone to help with this feature. Thanks again for taking the time.
February 16, 2012 at 11:24 am #15276Jonah
ParticipantNo problem Jason, hopefully that steered you in the right direction.
July 4, 2015 at 5:00 pm #975633Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Looking for a way to merge Event Category with Blog Category’ is closed to new replies.
