• Resolved wordmax

    (@wordmax)


    Hi,

    What is the best most efficient way to insert desired [shortcode] into strings of code in Ad Inserter blocks?

    For example, maybe we want to put a link to a Google search based on the post title.

    Post title is “How to Buy Bitcoin”
    So Google search url would look like:

    "https://www.google.com/search?q=how+to+buy+bitcoin"

    But we want to use shortcode in URL so all posts will have link to Google search based on the UNIQUE post title. So we would try something like this…

    Ad Block content:

    <a title="[adinserter data='title']" href="https://www.google.com/search?q=[adinserter data='title']">[adinserter data='title'] - Google Search!</a>

    But this does not work in Ad Inserter block because the shortcode does not get processed before the query to Google. We have found a workaround using custom functions to create shortcodes, but… is there a better and easier way to make it work just by using Ad Inserter blocks to handle the necessary custom functions?

    Thank you for making an awesome plugin!

    • This topic was modified 6 years, 1 month ago by wordmax.
    • This topic was modified 6 years, 1 month ago by wordmax.
    • This topic was modified 6 years, 1 month ago by wordmax.

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Spacetime

    (@spacetime)

    Hello,

    the shortcodes in Ad Inserter blocks are processed.
    https://adinserter.pro/documentation/manual-insertion#shortcodes

    You also need to encode the data to be used in the url.

    <a title="[adinserter data='title']" href="https://www.google.com/search?q=<?php urlencode (do_shortcode ("[adinserter data='title']")); ?>">[adinserter data='title'] - Google Search!</a>

    Please enable remote debugging to check your page.
    https://ww.wp.xz.cn/support/topic/ad-inserter-support-before-you-ask-for-help/

    Thread Starter wordmax

    (@wordmax)

    Hi thanks for your help!

    The code you gave above did not work for me.

    I tried using this instead and it works well inside an adblock running in both the php mode or non-php mode. Do you think it matters whether I use the php or non-php mode?

    <?php urlencode (do_shortcode ("[adinserter data='title']")); ?>
    <a title="[adinserter data='title']" href="https://www.google.com/search?q=[adinserter data='title']">[adinserter data='title'] - Google Search</a>

    Also I would be cool if you put a discreet Paypal donation button on the plugin’s WP admin/setting screen. Nothing obtrusive, but just an easy way for users like me to send random donations as needed. Thanks!

    • This reply was modified 6 years, 1 month ago by wordmax.
    • This reply was modified 6 years, 1 month ago by wordmax.
    • This reply was modified 6 years, 1 month ago by wordmax.
    Plugin Author Spacetime

    (@spacetime)

    But you have PHP code in the block?

    In urls you need to urlencode the data.

Viewing 3 replies - 1 through 3 (of 3 total)

The topic ‘How to insert [shortcode] into HTML or other code in blocks?’ is closed to new replies.