我有问题将标题添加到标题:p
我刚刚创建了自定义的帖子类型。现在我想从自定义帖子类型的元素中获得随机标题,并在post(标准帖子)后编写它,这是我的代码:
function pobierajslowa() {
$args=array(
'orderby' => rand,
'post_type' => 'slowa_kluczowe_wpisu',
'posts_per_page' => 1,
'caller_get_posts'=> 1
);
$queryObject = new WP_Query($args);
while ($queryObject->have_posts()) {
$queryObject->the_post();
return get_the_title();
}
}
function theme_slug_filter_the_content( $title ) {
$custom_content = $title;
$custom_content .= ' '.pobierajslowa().'';
return $custom_content;
}
add_filter( 'the_title', 'theme_slug_filter_the_content' );
当我使用这个之后,我得到503错误:O我做错了什么?
'orderby' => rand,
应该是…
'orderby' => 'rand', // a string
请务必仔细检查语法。打开WP_Debug
会告诉您问题所在。