duanjiyun7391 2013-04-28 21:17
浏览 82
已采纳

WordPress包裹div里面的echo shortcode php

I'm trying to wrap a div using a shortcode that I'm calling from within my themes template.

So far I have this:

<?php echo do_shortcode('[tooltip content="Delete" url=""]'.<div class="delete-button-comments"><?php if ( bp_activity_user_can_delete() ) bp_activity_delete_link(); ?></div>.'[/tooltip]'); ?>

but I'm getting a syntax error (which I know why) but if I delimit the periods and apostrophes nothing happens at all.

So basically I would like to wrap the tooltips shortcode around the div that displays the icon that the div displays.

  • 写回答

1条回答 默认 最新

  • duandi1636 2013-04-28 21:46
    关注

    bp_activity_delete_link echoes the link, you should use bp_get_activity_delete_link() to return the value. Not exactly sure what you're trying to do, maybe something like:

    <?php
        $link = ( bp_activity_user_can_delete() ) ? '<div class="delete-button-comments">' . bp_get_activity_delete_link() . '</div>' : '';
        echo do_shortcode('[tooltip content="Delete" url=""]' . $link . '[/tooltip]');
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥100 Jenkins自动化部署—悬赏100元
  • ¥15 关于#python#的问题:求帮写python代码
  • ¥20 MATLAB画图图形出现上下震荡的线条
  • ¥15 关于#windows#的问题:怎么用WIN 11系统的电脑 克隆WIN NT3.51-4.0系统的硬盘
  • ¥15 perl MISA分析p3_in脚本出错
  • ¥15 k8s部署jupyterlab,jupyterlab保存不了文件
  • ¥15 ubuntu虚拟机打包apk错误
  • ¥199 rust编程架构设计的方案 有偿
  • ¥15 回答4f系统的像差计算
  • ¥15 java如何提取出pdf里的文字?