• Hello good work with the plugin, i have a problem, i need to put category name next to isotope-item class to sort with the filters.

    <div class="models-shortcode models-grid <?php echo esc_attr( $margin_class ); ?>
    	 items-xs-4	items-sm-4	items-md-4	items-lg-4">
    <div class="isotope_container isotope row masonry-layout">
    
    <div class="isotope-item col-lg-3 col-md-3 col-sm-3 col-xs-3 <?php 
    $cat = get_query_var('cat');
       $category = get_category ($cat);
       echo ''.$category->cat_name.'';
    ?>" style="padding: 10px 10px 10px 10px;">
    				
    				
    <?php
    					include( fw()->extensions->get( 'models' )->locate_view_path( 'loop-item' ) );
    				?>
    
    </div></div></div>

    Thanks in advance.
    PD: Sorry for my english low level.

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @pixysve,
    Here is an example in the loop.
    https://stackoverflow.com/a/41382897/921927

    <?php
    $categories = get_the_category();
    $classes = '';
    if ( ! empty( $categories ) ) {
      foreach ( $categories as $cat ) {
        $classes .= $cat->slug . ' ';
      }
    }
    ?>
    <div class="isotope-item col-lg-3 <?php echo ''. $classes .'';
    ?>" style="padding: 10px 10px 10px 10px;">
    	
    </div>
    Thread Starter pixysve

    (@pixysve)

    Thanks @dcooney but the code dont work, still not show the category name.

    Any idea?

    Plugin Author Darren Cooney

    (@dcooney)

    Please share a link with this code in place please.

    Thread Starter pixysve

    (@pixysve)

    @dcooney

    https://www.tabuescort.cl/models/

    And this is the full code of the repeater

    <?php
    //column paddings class
    //margin values:
    //0
    //1
    //2
    //10
    //30
    $margin_class = '';
    switch ( $atts['margin'] ) :
    	case ( 0 ) :
    		$margin_class = 'columns_padding_0';
    		break;
    
    	case ( 1 ) :
    		$margin_class = 'columns_padding_1';
    		break;
    
    	case ( 2 ) :
    		$margin_class = 'columns_padding_2';
    		break;
    
    	case ( 10 ) :
    		$margin_class = 'columns_padding_5';
    		break;
    	//6
    	default:
    		$margin_class = 'columns_padding_15';
    endswitch;
    
    $unique_id = uniqid();
    
    ?>
    
    <div class="models-shortcode models-grid <?php echo esc_attr( $margin_class ); ?>
    	 items-xs-4	items-sm-4	items-md-4	items-lg-4">
    <div class="isotope_container isotope row masonry-layout">
    <?php
    $categories = get_the_category();
    $classes = '';
    if ( ! empty( $categories ) ) {
      foreach ( $categories as $cat ) {
        $classes .= $cat->slug . ' ';
      }
    }
    ?>
    <div class="isotope-item col-lg-3 col-md-3 col-sm-3 col-xs-3 <?php echo ''. $classes .''; ?>" style="padding: 10px 10px 10px 10px;">				
    				
    <?php
    					include( fw()->extensions->get( 'models' )->locate_view_path( 'loop-item' ) );
    				?>
    
    </div></div></div>
    • This reply was modified 6 years, 1 month ago by pixysve.
    Plugin Author Darren Cooney

    (@dcooney)

    It works for me on my test site.
    The issue is likely your items are not categories but a custom taxonomy.

    Thread Starter pixysve

    (@pixysve)

    @dcooney Thanks man, what i can do in this case?

    Plugin Author Darren Cooney

    (@dcooney)

    Hi @pixysve You need to figure out what the taxonomy is for this.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘Insert category name in class for sort’ is closed to new replies.