• Resolved davidtroeger

    (@davidtroeger)


    First of all, fantastic plugin! ??

    Is it possible to focus on the element eg. #results on the filtered results? I have an archive page with a bit of explanation above the fold, and the filter is below the fold, therefore it would be great if the filtered results could focus on my element rather than start on top.

    Thank you,
    Dave

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Jonathandejong

    (@jonathandejong)

    Hi Dave,

    Thank you ?? I hope it will just get better.

    I think in the long term I could make some improvement where BTF adds contextual classes to the body element of the archive page. That would allow you to use them for both styling and scripts.

    I think the easiest way to achieve what you want right now is to add your own class to body.

    something like this for the class:

    
    function btf_body_classes( $classes ) {
    	if ( is_tax() && is_post_type_archive( 'myposttype' ) ) {
    		$classes[] = 'btf-filtered';
    	}
        return $classes;
    }
    add_filter('body_class', 'btf_body_classes');
    

    You might want to do some more specific checks in the if.

    And then a short JS check which scrolls to your #results element.

    
    if( $('body').hasClass('btf-filtered') ){
    	$('html, body').animate({
    		scrollTop: $('#results').offset().top
    	}, 400);
    }
    
    Thread Starter davidtroeger

    (@davidtroeger)

    Hi Jonathan,

    Great, thanks for the quick reply! In combination with the new classes that check if the page is filtered I can do just what I wanted. Fantastic! ??

    Plugin Author Jonathandejong

    (@jonathandejong)

    No problem!
    Best of luck with your project.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Filter results element’ is closed to new replies.