• Resolved wordmax

    (@wordmax)


    Hello:
    Is it possible or recommended to use Ad Inserter to add custom functions?
    If so, what is the best way to do this?
    Is there any documentation about it?

    Sorry if answer exists, I searched and didn’t see anything about custom functions.
    Thanks!

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

    (@spacetime)

    What do you mean by “custom functions”?

    Thread Starter wordmax

    (@wordmax)

    For example, I created a custom function so I can insert shortcode on a page or post to display tag cloud within. The function can be added to the theme’s functions.php file but it will get over-written with a theme update. So I can use a plugin like My Custom Functions to insert/add my custom function, but I would use Ad Inserter instead to include the function if it works so I don’t use an extra plugin if it’s not necessary.

    custom function example for tag cloud shortcode:
    add_shortcode( 'native_tagcloud', 'wp_tag_cloud' );

    Plugin Author Spacetime

    (@spacetime)

    No need to create a function.
    You can use Ad Inserter shortcodes to insert arbitrary HTML/Javascript/CSS/PHP code in any page or post:
    https://adinserter.pro/documentation/manual-insertion#shortcodes

    Thread Starter wordmax

    (@wordmax)

    Good to know thanks. So, for example, I can implement this custom function and shortcode using Ad Inserter?

    I’m not sure how…will have to trial and error I guess.

    // create [custom_rss] shortcode
    add_shortcode( 'custom_rss', 'execute_custom_rss_shortcode' );
    function execute_custom_rss_shortcode() {
      return do_shortcode('[wp_rss_retriever url="https://news.google.com/rss/search?q=' . get_the_title() . '&hl=en-US&gl=US&ceid=US%3Aen" items="8" excerpt="50" read_more="true" credits="false" new_window="true" cache="1800"]');
    }
    • This reply was modified 5 years, 7 months ago by wordmax.
    • This reply was modified 5 years, 7 months ago by wordmax.
    Plugin Author Spacetime

    (@spacetime)

    If I understand your needs correctly you simply configure one block with your (long) shortcode

    [wp_rss_retriever url="https://news.google.com/rss/search?q=<?php get_the_title(); ?>&hl=en-US&gl=US&ceid=US%3Aen" items="8" excerpt="50" read_more="true" credits="false" new_window="true" cache="1800"]

    and enable PHP processing and Ad Inserter shortcode for this block.

    Assuming this is block 1 with name “Custom RSS” you can then use in posts either

    [ADINSERTER block="1"]
    or
    [ADINSERTER name="Custom RSS"]

    You can also use Ad Inserter shortcode [ADINSERTER data='title'] to get post/page title but I’m not sure how it will behave nested in other shortcodes.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Custom Functions’ is closed to new replies.