Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #1376000

    Hi,

    So im using the post slider element and im looking to add the categories to it. I see there is a function created to add it to the other post grid element but I need it for the post slider.

    Do you have something that will work for me?

    Thanks

    #1376146

    Hey,

    Thanks for contacting us!

    Could you please elaborate on the changes you would like to make and share a link of the function you mentioned about post grid?

    Best regards,
    Yigit

    #1376184

    im trying to have the category of the post show up when using the post slider. I know there is a function that will let me do this for the post grid module but there is none for the post slider. I just want to display what category the post is in on the website under or above the title of the post that gets pulled in.

    #1376319

    Hi acscreativenew,

    Please try to add this in your functions.php (child theme):

    function enfold_post_slider_meta_content($meta_content, $entry, $index, ) {
        $categories = get_the_category($entry->ID);
        $separator = ' ';
        $output = '<div class="slide-meta-del">/</div><div class="postslider-category">';
        
        if ( ! empty( $categories ) ) {
    	        foreach( $categories as $category ) {
    				$output .= '<span alt="' . esc_attr( sprintf( __( 'View all posts in %s', 'textdomain' ), $category->name ) ) . '">' . esc_html( $category->name ) . '</span>' . $separator;
    	        }
    	    }
    	$output .= '</div>';
    
        return $meta_content . $output;
    }
    
    add_filter('avf_post_slider_meta_content', 'enfold_post_slider_meta_content', 10, 4);

    Hope it helps.

    Best regards,
    Nikko

    #1376330

    Thanks for the reply but it did not work.

    Could it be because the items being pulled to the post slider is not true “post”, its a custom post type and a custom taxonomy. you can see them below.

    also the code did throw an error when i first added it in. I had to remove the “,” after “$index” on the first line.

    #1376340

    Hi acscreativenew,

    Try to replace:

    $categories = get_the_category($entry->ID);

    with:

    $categories = get_the_terms( $entry->ID, 'taxonomy' );

    just change taxonomy with the correct taxonomy name.
    You can check further information here: https://developer.wordpress.org/reference/functions/get_the_terms/

    Best regards,
    Nikko

    #1376343

    Sorry this is still not working, even in its most simple for of just trying to insert the code into that section to see the HTML

    
    function enfold_post_slider_meta_content($meta_content, $entry, $index ) {
        $output = '<div class="slide-meta-del">/</div><div class="postslider-category">';
    	$output .= '<span class="cat"><a href="#">test</a></span>';
    	$output .= '</div>';
    
        return $meta_content . $output;
    }
    
    add_filter('avf_post_slider_meta_content', 'enfold_post_slider_meta_content', 10, 4);
    

    Before that I tried a number of different ways to call the custom term.

    #1376349

    Hi acscreativenew,

    Can you give us temporary admin access? so we can check it.
    Or you can create a staging site for us, if the site is already live.

    Best regards,
    Nikko

    #1376350

    Thank You!

    #1376359

    Hi acscreativenew,

    Which page are you referring? I tried to check on the homepage but I only saw a content slider, I have checked some pages but did not find it.

    Best regards,
    Nikko

    #1376422

    ohh sorry i forgot to post the link.

    #1377069

    Hi acscreativenew,

    I apologize for the delayed response.
    It seems the code I gave was not needed, I have commented out the php code I gave however I have modified your Reviews cpt and in includes/custom-post-types.php line 348, I changed:

    'hierarchical' => true,

    to:

    'hierarchical' => false,

    and in Quick CSS, I have added this CSS code:

    .avia-content-slider-inner .slide-meta {
        display: none;
    }

    Please review your site.

    Best regards,
    Nikko

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