doupa9062 2014-05-21 05:50
浏览 40
已采纳

如何在另一个函数中执行php函数?

I want to show a css button and text field in PHP(functions.php of WordPress theme).

I am able to do everything but the issue is just the value="<?php echo wp_get_shortlink(get_the_ID()); ?>" which does't execute if I use double quotes.

Here is my code:

function add_buttons_filter( $content ) {


      $content .= ' <span class="abf">
                    <span class="abc">
                        <button class="bcd"><span class="dcb"><span></span></span> 
                        </button>
                    </span>
                    <span class="abf">
                            <span class="abc-main">
                            <span class="abc-box" style="display:none;"> 
                                <input type="text" style=" max-width: 80px;" value="<?php echo wp_get_shortlink(get_the_ID()); ?>" onclick="this.focus(); this.select();" />
                            </span>
                            </span>
                    </span>
                    </span>';    
return $content;

}
add_filter( 'the_content', 'add_buttons_filter' );

Could any one help me or show me a better solution to execute this in functions.php ?

  • 写回答

3条回答 默认 最新

  • donglie1898 2014-05-21 05:57
    关注

    Your statement is already embedded in php-Code, so it won't help to insert further code there - you can directly do the stuff:

    function add_buttons_filter( $content ) {
    
    
          $content .= ' <span class="abf">
                        <span class="abc">
                            <button class="bcd"><span class="dcb"><span></span></span> 
                            </button>
                        </span>
                        <span class="abf">
                                <span class="abc-main">
                                <span class="abc-box" style="display:none;"> 
                                    <input type="text" style=" max-width: 80px;" value="' .  wp_get_shortlink(get_the_ID()) . '" onclick="this.focus(); this.select();" />
                                </span>
                                </span>
                        </span>
                        </span>';    
    return $content;
    
    }
    add_filter( 'the_content', 'add_buttons_filter' );
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
  • ¥50 汇编语言除法溢出问题
  • ¥65 C++实现删除N个数据列表共有的元素
  • ¥15 Visual Studio问题
  • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
  • ¥20 求一个html代码,有偿
  • ¥100 关于使用MATLAB中copularnd函数的问题
  • ¥20 在虚拟机的pycharm上
  • ¥15 jupyterthemes 设置完毕后没有效果
  • ¥15 matlab图像高斯低通滤波