Trying to call dynamic content as a shortcode attribute
I'm trying to add a dynamic attribute to an existing (3rd party) shortcode. The shortcode appears several times on the same page. When I do this (in my functions.php), I can get the first shortcode to output correctly but the others don't.
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');
So as you can see, each shortcode is pulling the slug of the page it resides on (that's what I'm trying to achieve anyway). They're using "and" logic, and in each case, the student is different.
Why is only the first instance working? I wish I knew more about all this stuff!
Thanks in advance folks, Mike
Topic shortcode wordpress.com-hosting Wordpress
Category Web