-
AuthorPosts
-
December 12, 2022 at 11:12 pm #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
December 14, 2022 at 2:59 pm #1376146Hey,
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,
YigitDecember 14, 2022 at 4:34 pm #1376184im 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.
December 16, 2022 at 3:00 am #1376319Hi 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,
NikkoDecember 16, 2022 at 3:47 am #1376330Thanks 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.
December 16, 2022 at 5:52 am #1376340Hi 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,
NikkoDecember 16, 2022 at 6:08 am #1376343Sorry 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.
December 16, 2022 at 6:50 am #1376349Hi 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,
NikkoDecember 16, 2022 at 7:07 am #1376350Thank You!
December 16, 2022 at 7:49 am #1376359Hi 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,
NikkoDecember 16, 2022 at 3:43 pm #1376422ohh sorry i forgot to post the link.
December 22, 2022 at 8:37 am #1377069Hi 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 -
AuthorPosts
- You must be logged in to reply to this topic.