我正在尝试向现有(第三方)短代码添加动态属性。短代码在同一页上出现多次。当我这样做时(在functions.php中),我可以得到第一个正确输出的短代码,但其他的则不行。
function testOne(){
return do_shortcode(\'[abc type="contact" orderby="menu_order" order="asc" style="list-post" logic="and" abc_tax_student="student1" abc_tax_teacher="\'.basename(get_permalink()).\'"]\');
}
add_shortcode(\'shortcode1\', \'testOne\');
function testTwo(){
return do_shortcode(\'[abc type="contact" orderby="menu_order" order="asc" style="list-post" logic="and" abc_tax_student="student2" abc_tax_teacher="\'.basename(get_permalink()).\'"]\');
}
add_shortcode(\'shortcode2\', \'testTwo\');
function testThree(){
return do_shortcode(\'[abc type="contact" orderby="menu_order" order="asc" style="list-post" logic="and" abc_tax_student="student3" abc_tax_teacher="\'.basename(get_permalink()).\'"]\');
}
add_shortcode(\'shortcode3\', \'testThree\');
因此,正如您所看到的,每个短代码都在拉动它所在页面的slug(这就是我正在努力实现的)。他们使用“和”逻辑,在每种情况下,学生都是不同的。为什么只有第一个实例有效?我希望我对这些东西了解得更多!
提前谢谢各位,迈克