this is my shotcode:
function ctest_shortcode($atts) {
extract(shortcode_atts(array(
'a' => '11111'
), $atts));
ob_start();
include(locate_template('test.php'));
return ob_get_clean();
}
add_shortcode('test', 'ctest_shortcode');
this is test php file
<?phpif ( ! defined( 'ABSPATH' ) ) {exit( 'Direct script access denied.' );}
$posts = get_posts(array(
'posts_per_page' => -1,
'post_type' => 'mynews',
'tax_query' => array(
array(
'taxonomy' => 'newstypes',
'field' => 'tag_ID',
'terms' => array($a) // shortcode parameter $a variable
),),));
if( $posts ): ?>
<?php foreach( $posts as $post ):
setup_postdata( $post );?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php echo get_field('link'); ?>
<?php endforeach; ?>
<?php endif; wp_reset_postdata(); ?>
Template shows only variable a it do not showing title and act field link