我想知道如何在自定义文件中打印变量WP_Query
.
我有以下代码:
<?php
$args = array (
\'post_type\' => \'post\',
\'posts_per_page\' =>3,
\'orderby\' => \'date\',
\'order\' => \'DESC\',
);
$loop = new WP_Query( $args );
endwhile;
wp_reset_query();
我在一个名为
$post_type_name
.
但是,当将其添加到我的代码中时
<?php
$post_type_name = get_sub_field(\'post_type_name\');
$args = array (
\'post_type\' => \'$post_type_name\',
\'posts_per_page\' =>3,
\'orderby\' => \'date\',
\'order\' => \'DESC\',
);
$loop = new WP_Query( $args );
endwhile;
wp_reset_query();
代码中断。有什么想法吗?有什么问题吗?