简体   繁体   中英

WordPress Widgets Off Site

So let me start off by giving a little information on what I am doing, I am creating an HTML5 WebApp (full-screen mode) for a church that does audio productions and online ministry sermon video and non-video posts, I decided to build it on top of WordPress, so they can allow multiple user's to easily customize the content of the pages inside the webapp as well as, post new content. So WordPress is installed inside the root directory, the web app is in the /app directory. The only issue I am running into is there is a widget based plugin that feeds up the events from Facebook, its really well done and I want to use it in the webapp. I cannot figure out an easy way to serve it up to the webapp. My latest effort was to build it into a post and serve that particular post up over PHP, well that fails miserably because once it gets to the webapp it has no idea how to handle the shortcode other than as plain text.

define('WP_USE_THEMES', false);
require('../wp-blog-header.php');

<?php
$post_id = 17;
$queried_post = get_post($post_id);
$title = $queried_post->post_title;
echo $queried_post->post_content;
?>

Not sure why I thought that would work because obviously, it has no idea what the short code in the post is other than plain-text. Is there a file or files I can just include so that it will understand how to handle the widget and display it correctly or should I just get started on building what it does in its owns no dependency form?

Any help would be greatly appreciated.

Try something like:

echo do_shortcode( $queried_post->post_content );

That should parse any shortcodes contained in the post content, and run them through their corresponding hooks.

Reference: https://developer.wordpress.org/reference/functions/do_shortcode/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM