Viewing 1 replies (of 1 total)
  • Plugin Author Mat Lipe

    (@mat-lipe)

    Hi Jeremy,

    If you add this filter to your functions.php file, you should be able to use slugs within your shortcodes.

    /**
     * Allow category slugs to be used in place of category names
     */
    add_filter( 'simple_links_args', 'sl_use_category_slugs' );
    function sl_use_category_slugs($args) {
    
    	if( !is_array( $args[ 'category' ] ) ) {
    		$args[ 'category' ] = explode( ',', $args[ 'category' ] );
    	}
    
    	//swap from slug to name
    	foreach( $args['category'] as &$cat ) {
    		$cat =  get_term_by( 'slug', $cat, Simple_Links_Categories::TAXONOMY )->name;
    	}
    
    	return $args;
    
    }

    You will have to add the slugs to the shortcode manually and I just wrote this snippet from memory, so it may need to be adjusted.

    Hope this helps!

Viewing 1 replies (of 1 total)

The topic ‘Filter using category slug’ is closed to new replies.