Tagged: custom query, post slider
Post slider with custom query
-
CreatorTopic
-
June 27, 2014 at 5:11 am #17517
mmnmbk
ParticipantHi,
I’d like to seek support to make a post slider with custom type posts data. (All in one event calendar)
Could you advice how I can set Custom query to get custom type posts data with their category name?Here are conditions:
post_type=event_post_type &&
taxonomy_name = events_categories &&
term = family-eventsAlso I would like to take posts data as well in one query. Is it possible?
Thanks,
-
CreatorTopic
-
AuthorReplies
-
June 27, 2014 at 9:48 pm #17522
Jason Bobich
KeymasterHello,
I believe it would be formatted something like this:
post_type={post_type}&{taxonomy}={term}
So, assuming what you stated above is correct, it would be like this:
post_type=event_post_type&events_categories=family-events
June 28, 2014 at 3:43 am #17528mmnmbk
ParticipantHi Jason,
Thank you for your comment.
I tried the query, which you gave me. Now I can retrieve event data but it seems that the taxonomy is ignored… as a custom query ” events_categories=family-events” cannot get any data. Taxonomy&term are correct for sure.Do you have any idea?
June 28, 2014 at 7:17 pm #17532Jason Bobich
KeymasterYou could try doing an actual tax query through PHP from your child theme, using this basic concept:
http://dev.themeblvd.com/tutorial/extending-the-custom-query/
Except, in this case, you’d want to use the filter “themeblvd_slider_auto_args” something like:
[post_slider query="my_unique_key"]
/** * Custom query for post slider */ function my_custom_posts_query( $query, $args ){ if( $args['query'] == 'my_unique_key' ){ $query = array( 'post_type' => 'event_post_type', 'tax_query' => array( array( 'taxonomy' => 'events_categories', 'field' => 'slug', 'terms' => 'family-events' ) ) ); } return $query; } add_filter( 'themeblvd_posts_args', 'my_custom_posts_query', 10, 2 );
http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters
June 29, 2014 at 9:02 am #17535mmnmbk
ParticipantHi Jason,
Thank you for your reply. I added the custom query function (my_custom_posts_query) to my functions.php and call the shortcode from page. but it didn’t work. The 5 latest POST data is shown.
Also I tried to set “Custom Query” on “Where to pull post from?” option & set “my_unique_key” on “Custom Query” option under Post slider at page builder. but no luck….I cleared value on Custom Query option as blank. The 5 latest POST data is shown as well.
I modified the function to take data with other term, but the 5 latest POST data is shown as well.Sorry again.. do you have any idea? Appreciate your support. Thanks.
June 29, 2014 at 9:06 pm #17536Jason Bobich
KeymasterThese are the only ways I know to query posts by a custom post type and taxonomy.
June 29, 2014 at 9:21 pm #17538Jason Bobich
KeymasterIs this the plugin you’re using?
https://wordpress.org/plugins/all-in-one-event-calendar/
I just downloaded it and the registered custom post type is
ai1ec_event
and the associated, registered taxonomies are:events_categories
events_tags
events_feeds
Could the issue be that you had the post type wrong?
-
AuthorReplies
- The forum ‘Akita Responsive WordPress Theme’ is closed to new topics and replies.