admin管理员组文章数量:1404468
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
本文标签: categoriesWordpress Portofolio Conditional Templatingfunctions php
版权声明:本文标题:categories - Wordpress Portofolio Conditional Templating - functions php 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744801563a2625892.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论