最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

plugins - How to add social locker on custom fields

programmeradmin1浏览0评论

i want to add social locker on custom fields like demo and download buttons

<center><p><a class="mbutton" target="_blank" href="<?php echo get_field(demo_link); ?>">DEMO</a><p></center>
<center><p><a class="dbutton" target="_blank" href="<?php echo get_field(download_link); ?>">DOWNLOAD</a><p></center>

i tried to use <?php echo do_shortcode("[lockercat]"); ?> added here buttons <?php echo do_shortcode("[/lockercat]"); ?>

..... with this locker works now but get_field function doesnt work and getting link like this

example/post-name/php echo get_field(download_link); ?>

....

<?php
$lockit = '[lockercat]' . '<center><p><a class="mbutton" target="_blank" href="<?php echo get_field(demo_link); ?>">DEMO</a><p></center>
                            <center><p><a class="dbutton" target="_blank" href="<?php echo get_field(download_link); ?>">DOWNLOAD</a><p></center>' . '[/lockercat]';
echo do_shortcode($lockit);
?>

i want to add social locker on custom fields like demo and download buttons

<center><p><a class="mbutton" target="_blank" href="<?php echo get_field(demo_link); ?>">DEMO</a><p></center>
<center><p><a class="dbutton" target="_blank" href="<?php echo get_field(download_link); ?>">DOWNLOAD</a><p></center>

i tried to use <?php echo do_shortcode("[lockercat]"); ?> added here buttons <?php echo do_shortcode("[/lockercat]"); ?>

..... with this locker works now but get_field function doesnt work and getting link like this

example/post-name/php echo get_field(download_link); ?>

....

<?php
$lockit = '[lockercat]' . '<center><p><a class="mbutton" target="_blank" href="<?php echo get_field(demo_link); ?>">DEMO</a><p></center>
                            <center><p><a class="dbutton" target="_blank" href="<?php echo get_field(download_link); ?>">DOWNLOAD</a><p></center>' . '[/lockercat]';
echo do_shortcode($lockit);
?>
Share Improve this question edited Mar 26, 2018 at 20:50 Lashh a asked Mar 26, 2018 at 19:44 Lashh aLashh a 112 bronze badges 1
  • What's a social locker? Shortcodes have to be self contained, you can't pass [shortcode] in one call, then [/shortcode] in another – Tom J Nowell Commented Mar 26, 2018 at 20:09
Add a comment  | 

1 Answer 1

Reset to default 1

The do_shortcode() syntax requires everything in one string.

<?php
$lockit = '[lockercat]' . 'your buttons etc.' . '[/lockercat]';
echo do_shortcode($lockit);
?>
发布评论

评论列表(0)

  1. 暂无评论