最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

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

programmeradmin1浏览0评论

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 ) { ?>
        <style>
  .navegacion-posts {
      display: none;
  }
</style>
<?php }

Can someone help me with this? Thanks!

发布评论

评论列表(0)

  1. 暂无评论