categories - Wordpress Portofolio Conditional Templating - functions php

I'm trying to load some code depending on which portfolio category i am , but cant seem to get it quite right...I&

I'm trying to load some code depending on which portfolio category i am , but cant seem to get it quite right... I've read that portfolio categories are called taxonomies, but don't know if thats right.. tried this code in my functions.php but crashed my whole site!

add_action('wp_footer', 'ava_auto_click');
function ava_auto_click(){
$the_terms = get_the_terms( $post->ID , 'portfolio_entries');
for ($i=0;$i< count($the_terms); ++$i) {
    var_dump($the_terms[$i]);
if($the_terms[$i] =="projects"){     
?>
<script>
    window.onload = function(){     
        var elem = document.querySelector('.wrap-filter').querySelectorAll('li')
        var event = new Event('click');
        document.getElementById('projects').classList.remove('none')
        elem[0].setAttribute("data-filter", ".offices, .retail, .residential, .stands, .cultural");
        elem[0].firstElementChild.setAttribute("data-filter", ".offices, .retail, .residential, .stands, .cultural");
        elem[1].classList.toggle('active')
        elem[1].querySelector('a').click();

    }
</script>
<?php

    }
    else { 


        ?>
        <script>
            window.onload = function(){     
                var elem = document.querySelector('.wrap-filter').querySelectorAll('li')
                var event = new Event('click');
                document.getElementById('projects').classList.remove('none')
                elem[1].classList.toggle('active')
                elem[1].querySelector('a').click();

            }
        </script>
        <?php
         }
    }
}

Thanks in advance for the help!!

I think the main structure is right but the if and the $the_terms = get_the_terms( $post->ID , 'portfolio_entries'); might be wrong

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744801563a4594522.html

相关推荐

  • categories - Wordpress Portofolio Conditional Templating - functions php

    I'm trying to load some code depending on which portfolio category i am , but cant seem to get it quite right...I&

    2天前
    50

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信