Hide post navigation if current post is in a category with only one post


I have the CPT “proyectos” and the custom taxonomy “servicios”
I have navigation arrows inside the single CPT template to navigate between posts in the same category.
Some taxonomies have only one post so in this case I need to hide the navigation arrows.
I’m using Elementor so I can’t edit the php template.
My idea was to generate a css rule to hide the navigation only if the above conditions are met.

I was trying something like this but obviously it didn`t work:

<?php $categories = get_the_terms( $post, 'servicios' );

if ( count($categories) == 1 ) { ?>
  .navegacion-posts {
      display: none;
<?php }

Can someone help me with this?

, , xaifu 4 years 2020-03-23T12:51:50-05:00 0 Answers 103 views 0

Leave an answer