Php Reduxframework:can';t从选择字段选择的帖子中获取值

Php Reduxframework:can';t从选择字段选择的帖子中获取值,php,wordpress,woocommerce,redux-framework,Php,Wordpress,Woocommerce,Redux Framework,我有一个下拉选择字段来选择woocommerce产品编辑屏幕中的自定义帖子类型,需要输出所选帖子的ID 这段代码可以在我的前端工作,但是在与其他插件(这里是wplister)一起工作时遇到了问题。如果我硬编码了所选的post ID,那么一切都可以正常工作 function psg_table_frontend_shortcode($atts, $content = null) { global $psg_global; /* START creating HTML Object */

我有一个下拉选择字段来选择woocommerce产品编辑屏幕中的自定义帖子类型,需要输出所选帖子的ID

这段代码可以在我的前端工作,但是在与其他插件(这里是wplister)一起工作时遇到了问题。如果我硬编码了所选的post ID,那么一切都可以正常工作

function psg_table_frontend_shortcode($atts, $content = null) { 

global $psg_global; 


/* START creating HTML Object */    
ob_start();
?>
<p>
<?php 
echo "The ID of the selected sizing Guide (cpt) inside the Product  : " .$psg_global['psg-selected-sizing-guide-on-productpage'];
?>
</p>

$output = ob_get_clean();   
/* END creating HTML Object */

return $output; 
}

add_shortcode('psg_frontend', 'psg_table_frontend_shortcode'); 
函数psg\u table\u frontend\u shortcode($atts,$content=null){
全球$psg_全球;
/*开始创建HTML对象*/
ob_start();
?>

$output=ob_get_clean(); /*结束创建HTML对象*/ 返回$output; } 添加_短代码(“psg_前端”、“psg_表格_前端_短代码”);
与wplister的支持人员交谈,但他们说这可能是reduxframwork和全局变量的问题


有什么想法吗?

如果你在一个函数中,谁知道你的psg_global是否在范围内呢。。。所以试试这个:

$psg_global= get_option( 'psg_global'); // or whatever your opt name is
$productpage = $psg_global['psg-selected-sizing-guide-on-productpage']; 

echo $productpage;
此外,您可能希望使用带下划线的“psg\u selected\u Size\u guide\on\u productpage”而不是“psg selected Size guide on productpage”,因为这样您可以做到:

extract($psg_global)
你所有的VAR都在范围之内。 例如:

echo $psg_selected_sizing_guide_on_productpage

选择字段是redux框架字段吗
$psg_global['psg-selected-sizing-guide-on-productpage']
可能是一个数组,如果使用
foreach
循环通过它,您可能能够获得ID。