我正在使用 WP User Frontend Pro 插件我想使用简码来回显包标题以将其放入面包店视觉中。我所知道的是:这是标题 $pack->post_title;
$pack 来自这里:
public function current_pack() {
global $pack;
$pack = $this->pack;
if ( ! isset( $this->pack['pack_id'] ) ) {
$pack_page = get_permalink( wpuf_get_option( 'subscription_page', 'wpuf_payment' ) );
return new WP_Error( 'no-pack', sprintf( __( 'You must <a href="%s">purchase a subscription package</a> before posting', 'wp-user-frontend'), $pack_page ) );
}
// seems like the user has a pack, now check expiration
if ( $this->expired() ) {
return new WP_Error( 'expired', __( 'The subscription pack has expired. Please buy a pack.', 'wp-user-frontend' ) );
}
return $pack;
}
我尝试做这样的事情:
function wpc_shortcode_pack_title() {
global $pack;
return $pack->post_title;
}
add_shortcode( 'sub_name', 'wpc_shortcode_pack_title' );
为了解释更多,第 5 行中的选定代码在插件页面中正常工作,但我希望它作为简码
但它没有任何帮助吗?
慕标5832272