plugins - Is there a visual editor specifically for page snippetssections?

I am building a WordpressWoocommerce site, and developing a plugin for it.In the plugin I am including some PHP html te

I am building a Wordpress/Woocommerce site, and developing a plugin for it.

In the plugin I am including some PHP html templates and hooking them into Wordpress in various ways.

Is there a way to visually compose and store these page snippets/sections somehow so that they can be viewed and edited in admin, through a visual composer?

I am envisioning something like Wordpress' page designer/editor, except just for page sections/snippets.

Thanks in advance!

I am building a Wordpress/Woocommerce site, and developing a plugin for it.

In the plugin I am including some PHP html templates and hooking them into Wordpress in various ways.

Is there a way to visually compose and store these page snippets/sections somehow so that they can be viewed and edited in admin, through a visual composer?

I am envisioning something like Wordpress' page designer/editor, except just for page sections/snippets.

Thanks in advance!

Share Improve this question edited May 5, 2019 at 13:30 Kerry Randolph asked May 4, 2019 at 17:20 Kerry RandolphKerry Randolph 993 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

I found that this can be done simply by using Wordpress' Page editor. Nothing else is needed:

  1. Compose the content in Wordpress' Page editor
  2. Save (but don't publish)
  3. In your code, retrieve the saved content

By ID:

$id=47;
$post = get_post($id);
$content = apply_filters('the_content', $post->post_content); 
echo $content;

Or by page title:

$title = 'page title';
$page = get_page_by_title( $title );
$content = apply_filters('the_content', $page->post_content); 
echo $content;

Note that apply_filters is used in case there is a plugin somewhere that wants to "apply filters" to the_content - it's good for forwards compatibility.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745522739a4631334.html

相关推荐

  • plugins - Is there a visual editor specifically for page snippetssections?

    I am building a WordpressWoocommerce site, and developing a plugin for it.In the plugin I am including some PHP html te

    19小时前
    20

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信