Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1020899

    Hello,

    I am using the Content Element – Blog Posts to show 4 Featured posts on a page. Is there a way to also show a Tribe Events Category within the Featured 4?

    For example if I choose Display Blog Posts and choose category “Featured” my generated shortcode looks like this:

    [av_blog blog_type='posts' categories='369' link='category' blog_style='blog-grid' columns='4' contents='title' content_length='content' preview_mode='auto' image_size='portfolio' items='4' offset='0' paginate='no' conditional='' av_uid='av-jn6k96no' custom_class='']

    If I choose Display entries form a custom taxonomy, choose Tibe Events Cat and then “Featured Event” category my shortcode looks like below:

    [av_blog blog_type='taxonomy' categories='369' link='tribe_events_cat,370' blog_style='blog-grid' columns='4' contents='title' content_length='content' preview_mode='auto' image_size='portfolio' items='4' offset='0' paginate='no' conditional='' av_uid='av-jn6k96no' custom_class='']

    How can I combine the two blog types & categories? Is there a way in this shortcode and then I would drop it in the Custom code element? Thank you so much!

    #1022868

    Hey aarynm,

    Thank you for using Enfold.

    You can try this filter in the functions.php file.

    // blog posts and event query
    add_filter( 'avia_post_slide_query', 'avia_post_slide_query_mod', 1000, 2);
    function avia_post_slide_query_mod( $query, $params ) {
        $posts = get_posts(
            array(
                'posts_per_page' => 3,
                'categories' => 369
            )
        );
    
        $event =  tribe_get_events( array(
            'posts_per_page' => 1,
            'tax_query'=> array(
                array(
                    'taxonomy' => 'tribe_events_cat',
                    'field' => 'term_id',
                    'terms' => array(370)
                )
            )
        ) );
    
        foreach($posts as $post) {
            $include[] = $post->ID;
        }
    
        $include[] = $event[0]->ID;
    
        if ( ! is_admin() ) {
            array_unshift_assoc($query['tax_query'], 'relation', 'OR');
            $query['tax_query'][] =  array(
    			'taxonomy' => 'tribe_events_cat',
    			'field'    => 'term_id',
    			'terms'    => array(38),
    			'operator' => 'IN',
            );
    
            $query['post__in'] =  $include;
            $query['post_type'][] = 'tribe_events';
        }
    
    	return $query;
    }

    Best regards,
    Ismael

    #1022989

    Thank you. When I add to functions.php in my Child Theme I get the error

    Your PHP code changes were rolled back due to an error on line 9 of file wp-content/themes/enfold-child/functions.php. Please fix and try saving again.
    Call-time pass-by-reference has been removed; If you would like to pass argument by reference, modify the declaration of add_filter().

    Line 9 is $posts = get_posts(
    of the code below….
    add_filter( 'avia_blog_post_query', 'avia_blog_post_query_mod', 1000, 2); function avia_blog_post_query_mod( $query, $params ) {
    $posts = get_posts(
    array(
    'posts_per_page' => 3,
    'categories' => 369
    )
    );

    I tried uploading via FTP instead of using Editor and I got the white screen of death. LOL. If you can help with the code above then great, if not it’s ok too. I realize I might be pushing the support you offer. I have a workaround just trying to save some time with this solution.

    #1023306

    Hi,

    It is working properly on my end. Did you copy the code from your email? Please copy it directly from the forum. Or post the FTP login details in the private field, so that I can add it for you.

    Best regards,
    Ismael

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.