when try run shortcode code:
define( 'wp_use_themes', false ); require_once('account/wp-blog-header.php'); require_once('account/wp-includes/shortcodes.php'); global $current_user; get_currentuserinfo(); print_r($current_user); get_header(); $page_object = get_page( 28 ); var_dump($page_object); echo do_shortcode($page_object->post_content);
i page header, do_shortcode didn't work. dump of page_object returns me this:
object(wp_post)[276] public 'id' => int 28 public 'post_author' => string '1' (length=1) public 'post_date' => string '2015-09-22 12:14:16' (length=19) public 'post_date_gmt' => string '2015-09-22 12:14:16' (length=19) public 'post_content' => string '[pmpro_levels]' (length=14) public 'post_title' => string 'membership levels' (length=17) public 'post_excerpt' => string '' (length=0) public 'post_status' => string 'publish' (length=7) public 'comment_status' => string 'closed' (length=6) public 'ping_status' => string 'closed' (length=6) public 'post_password' => string '' (length=0) public 'post_name' => string 'levels' (length=6) public 'to_ping' => string '' (length=0) public 'pinged' => string '' (length=0) public 'post_modified' => string '2015-09-22 12:14:16' (length=19) public 'post_modified_gmt' => string '2015-09-22 12:14:16' (length=19) public 'post_content_filtered' => string '' (length=0) public 'post_parent' => int 22 public 'guid' => string 'http://phpstack-10604-23437-55300.cloudwaysapps.com/account/membership-account-2/membership-levels/' (length=99) public 'menu_order' => int 0 public 'post_type' => string 'page' (length=4) public 'post_mime_type' => string '' (length=0) public 'comment_count' => string '0' (length=1) public 'filter' => string 'raw' (length=3)
and $page_object->post_content;
returns me [pmpro_levels], do_shortcode()
doesn't parse shortcode. works inside wordpress directory, can see upwhere call wp-blog-header.php, didn't work. why?
you should try apply_filter
$content = apply_filters('the_content', $content);
apply_filters('the_content', $content); used apply content filters raw unfiltered post content, comes use of $post->post_content. these filters include famous filter wp_autop adds p tags the_content()
apply_filters('the_content', $content); usally used in conjuction get_posts 1 works directly wp_post objects without using setup_postdata( $post ) makes template tags the_content() available use
update - how code should be
get_header(); $page_object = get_page( 28 ); echo apply_filters('the_content', $page_object->post_content);
Comments
Post a Comment