Support » Plugin: WordPress Infinite Scroll - Ajax Load More » Add custom button to filter

  • I need to add a button to show all contents (back to archive page) and probably a custom menu link. Something like this:

    ALL | Category A | Category B | Category C | LINK

    Is this possible?

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author dcooney

    (@dcooney)

    Hi @rizkysyazuli,
    Are you speaking about the Filters add-on?

    You can add an ALL button if you are using the Custom Values parameter by using the alm_filters_{id}_{key} found below:
    https://connekthq.com/plugins/ajax-load-more/docs/add-ons/filters/#filter-hooks

    No you can’t add a custom link into the filters – this would have to be done with some custom JS but not with the plugin.

    Hope this helps.

    Yes. I was referring to the Filters add-on.

    Sorry but your instructions is not quite clear. Looking at that code example. Should i add a new item to the $values array, or what?

    Thx.

    One more thing, the custom link is kinda important for me because it will link to a “sitemap” kind-of page that list all my contents for fallback.

    Since your filter are checkboxes, which I don’t think is the most accessible thing for navigations. And just in case JS is not working or something like that.

    I know that this is not meant for navigations. But Is there a more appropriate way to do this?

    Thx

    Plugin Author dcooney

    (@dcooney)

    Hi @rizkysyazuli,

    For the ALL button, you could add an item to the return array using the custom filters.
    See the code below, which gets all categories then appends an All button.

    
    function my_filter_cats(){
    	
    	$values = []; // Define array
    	
    	// Get all categories 	
    	$args = array(
    		'orderby' => 'name',
    		'order'   => 'ASC'
    	);	
    	$terms = get_categories($args);	
    	if($terms){
    		foreach( $terms as $term ) {	
    			$values[] = array(
    				'label' => $term->name,
    				'value' => $term->slug
    		   );
    		}
    		
    		// Add custom 'All' value
    		$values[] = array(
    			'label' => 'All',
    			'value' => ''
    		);
    		
    		return $values; // Return values
    	}	
    	
    	return $values; // Return values	
    }
    add_filter( 'alm_filters_blog_category', 'my_filter_cats');
    

    One more thing, the custom link is kinda important for me because it will link to a “sitemap” kind-of page that list all my contents for fallback.

    As I mentioned, you could just create a link somewhere in your page template (or via JS) and move it into the filter list with JavaScript on page load.

    Since your filter are checkboxes, which I don’t think is the most accessible thing for navigations. And just in case JS is not working or something like that.

    The checkbox/radios are actually just styled links. You could use custom CSS to override the styling

    • This reply was modified 1 year, 6 months ago by  dcooney.

    okay, what values should i enter in this line:

    add_filter( 'alm_filters_{id}_{key}', 'my_filter_cats');

    * id is obviously the filter id. in my case it’s: menu_projects
    * key is not so obvious. what is this? right now i’m trying to filter a custom post type called “projects” using a custom taxonomy “project-category”.

    EDIT: nevermind.. i got it. it goes like this:

    add_filter( 'alm_filters_menu_projects_project-category', 'my_filter_cats');

    • This reply was modified 1 year, 5 months ago by  rizkysyazuli.
Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Add custom button to filter’ is closed to new replies.