我为 WordPress 编写的短代码有问题。我正在尝试使用该get_the_content()函数,但不是提取我创建的自定义帖子类型的内容,而是提取短代码所在页面的内容。其他功能都工作正常,例如get_the_title()和 g et_the_post_thumbnail()。我在函数中传递了 ID,它对于其他一切都非常有效,只是不适用get_the_content。
get_the_content($testimonial_item->ID);
Run Code Online (Sandbox Code Playgroud)
短代码包含分页和其他元素,它们都可以正常工作,只是这个功能让我感到悲伤。完整的代码如下,任何帮助将不胜感激。
function ncweb_display_testimonial_items($atts, $content = null) {
extract( shortcode_atts( array(
'per_page' => 6
), $atts ) );
/* pagination parameters */
// check what page we are on
if ( isset ($_GET['testimonial-page'] ) ) $page = $_GET['testimonial-page']; else $page = 1;
// default number of pages
$total_pages = 1;
// portfolio offset. Used in the get_posts() query to show only portfolio for the current page
$offset …Run Code Online (Sandbox Code Playgroud)