【问题标题】:Wordpress + PHP: Getting Option Value into VariableWordpress + PHP:将选项值放入变量中
【发布时间】:2012-02-19 12:27:03
【问题描述】:

我相信这对你们来说一定很容易,但我很难将我的主题选项值放入变量之一。

在下面的代码中,我必须使用“”作为值,并且我允许用户从 wordpress 主题选项面板插入该值。我不知道如何设置,所以我可以在这个变量中获取主题选项值。

$rate_size="echo get_option('mp_star_size')",

我试过了

$rate_size="'.echo get_option('mp_star_size').'",

但它给了我语法错误所以不知道我应该使用什么语法。

好吧,这里有更多我想要得到的细节

以下代码:

    wp_gdsr_render_article(

            $stars_set="",
            $stars_size=0,
            $stars_set_ie6="",
            $echo=true

        );

我想让我的主题用户从 wordpress 主题的主题选项面板中选择选项。所以我想用 echo get_option() 设置类似的东西,这样我就可以从选项面板中获取该代码的每个参数的值。

示例:

    wp_gdsr_render_article(

            $stars_set="here is my theme option",
            $stars_size=here is my theme option,
            $stars_set_ie6="here is my theme option",
            $echo=here is my theme option

        );

【问题讨论】:

    标签: php wordpress variables


    【解决方案1】:
    $rate_size = get_option('mp_star_size');
    

    echo 仅用于在页面上显示内容。

    【讨论】:

    • “”报价怎么样?因为它需要包装值......它没有输出到页面
    • 不,不是。引号分隔字符串,get_option() 返回一个字符串,所以你很好。发布您使用的确切代码和您得到的错误。
    • 错误是我的错误。这是我的主题选项array( "name" => "Star Size", "desc" => "Select size for star ratings.", "id" => $shortname."_star_size", "type" => "select", "options" => array("12" => "12", "16" => "16", "20" => "20", "24" => "24", "30" => "30", "46" => "46"), "std" => "12"), 前缀是 mp,我正在尝试连接我发布的代码
    • 这是我正在处理的函数function article_ratings($class) { echo '<div class="'.$class.'">'; wp_gdsr_render_article( $template_id=0, $read_only=false, $stars_set="", $stars_size=0, $stars_set_ie6="", $echo=true ); wp_gdsr_render_article_thumbs( $template_id=0, $read_only=false, $stars_set="", $stars_size=0, $stars_set_ie6="", $echo=true ); echo '</div>'; }
    • 酷它在许多情况下的工作让我与所有人联系并再次回复您.. :)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-15
    • 2020-11-10
    • 2017-03-22
    • 1970-01-01
    相关资源
    最近更新 更多