This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Post slider with custom query

  • Creator
    Topic
  • #17517
    mmnmbk
    Participant

    Hi,

    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-events

    Also I would like to take posts data as well in one query. Is it possible?

    Thanks,

Viewing 6 replies - 1 through 6 (of 6 total)
  • Author
    Replies
  • #17522
    Jason Bobich
    Keymaster

    Hello,

    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

    http://codex.wordpress.org/Class_Reference/WP_Query

    #17528
    mmnmbk
    Participant

    Hi 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?

    #17532
    Jason Bobich
    Keymaster

    You 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

    #17535
    mmnmbk
    Participant

    Hi 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.

    #17536
    Jason Bobich
    Keymaster

    These are the only ways I know to query posts by a custom post type and taxonomy.

    #17538
    Jason Bobich
    Keymaster

    Is 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:

    1. events_categories
    2. events_tags
    3. events_feeds

    Could the issue be that you had the post type wrong?

Viewing 6 replies - 1 through 6 (of 6 total)
  • The forum ‘Akita Responsive WordPress Theme’ is closed to new topics and replies.