在保存帖子wordpress上做短代码 [英] do shortcode on save post wordpress

查看:107
本文介绍了在保存帖子wordpress上做短代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在postmeta中保存使用do_shortcode提取短代码的内容。

我的问题是他使用的是do_shortcode,但他没有使用短代码的属性。



内容如:

Hello world我的名字是[name first =foolast =bar]。



使用此代码,我将内容保存在postmeta中:

I want to save the content in postmeta where shortcodes are extracted with do_shortcode.
My problem is that he use do_shortcode, but he doesn't take attributes of the shortcode.

the content like:
Hello world my name is [name first="foo" last="bar"].

With this code, I save the content in the postmeta:

function save($post_id){
if (isset($_REQUEST['content'])){
update_post_meta($post_id, 'custom', do_shortcode($_REQUEST['content']));
}
}





短代码喜欢这样:



shortcode likes this:

function name($atts){
return "firstname".$atts['first'].", lastname".$atts['last'];
}





当我查看phpmyadmin查看postmeta时,我看到了:

Hello world我的名字是姓,姓。



如何解决这个问题?



When I look in phpmyadmin to look the postmeta, i see this:
Hello world my name is firstname, lastname.

How can I fix this problem?

推荐答案

post_id){
if (isset(
post_id){ if (isset(


_REQUEST [' content'])){
update_post_meta(
_REQUEST['content'])){ update_post_meta(


post_id,' custom',do_shortcode(
post_id, 'custom', do_shortcode(


这篇关于在保存帖子wordpress上做短代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆