0

我最近在我的 wordpress 博客中安装了一个新模板(更具体地说是 SquirrelTheme - 免费模板)。碰巧我想在我的首页上有两个按钮。假设按钮 X 和按钮 Y。为了创建这些按钮,我使用了一个名为“MaxButtons”的插件,它允许您轻松创建和管理按钮及其功能。创建上述按钮后,它会为您提供一个短代码,您可以将其插入到您的帖子和页面中 - 比如说 [maxbutton id="1"] - 以显示它。

不幸的是,在根据我的喜好编辑模板(删除我不打算显示的 div)后,我似乎无法显示这两个按钮,因为模板解析纯文本,这与页面/帖子显然不同。

如果您想知道如何插入按钮的简码,可以通过仪表板轻松修改模板,在仪表板中,我在指示主页特定部分显示内容的字段中插入了以下内容:

[maxbutton id="1"]  [maxbutton id="2"]

就像我之前说的,我没有按预期显示按钮,而是准确地看到我在框中输入的内容。

我相信这是由模板如何解析文本引起的,因为它使用自己的函数(? - php _e('...')) 来回显文本:

<div class="full_content">
    <center>
    <?php if (squirrel_get_option('squirrel_slidehead') != '') { ?>
        <h1><?php echo stripslashes(squirrel_get_option('squirrel_slidehead')); ?></h1>
    <?php } else { ?>
        <h1><?php _e('We are scope, a design firm in England', 'squirrel'); ?></h1>
    <?php } ?>            
    <?php if (squirrel_get_option('squirrel_slidedesc') != '') { ?>
        <h2><?php echo stripslashes(squirrel_get_option('squirrel_slidedesc')); ?></h2>            
    <?php } else { ?>
        <p><?php _e('Newfoundland dogs are good to save children from drowning, but you must have a pond of water handy and a child.', 'squirrel') ?></p>
        <p><?php _e('From drowning, but you must have a pond of water handy and a child.', 'squirrel'); ?></p>
    <?php } ?>
    </center>    
    </div>

我的问题是,我怎样才能让它显示按钮或任何其他代码。

提前致谢。

4

1 回答 1

2

您可以调用该函数对某些文本do_shortcode()进行正确的短代码处理。

例子:

echo do_shortcode('This is a button: [maxbutton id="1"]');
于 2012-07-31T13:43:29.953 回答