• Resolved wordmax

    (@wordmax)


    Hi,

    I want to display RSS content on each post based on the title of each post.

    For example,
    [wp_rss_retriever url=”https://news.google.com/search?q=%5Bpost_title%5DE&hl=en-US&gl=US&ceid=US%3Aen” items=”10″ excerpt=”50″ read_more=”true” credits=”true” new_window=”true” thumbnail=”200″ cache=”7200″]

    I created a function for shortcode [post_title] in the theme functions.php file.

    function post_title_shortcode(){
        return get_the_title();
    }
    add_shortcode('post_title','post_title_shortcode');

    But it’s not working. I need the [post_title] value to be processed before the RSS url is checked. Right now it’s not.

    Any ideas how to make this concept work here?

    Thanks for your help!!

    • This topic was modified 5 years, 7 months ago by wordmax.
    • This topic was modified 5 years, 7 months ago by wordmax.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Travis

    (@tjtaylor)

    Hello,

    Using shortcodes inside attributes is not currently possible according to the Shortcodes API. However, you could follow the advice here to accept dynamic parameters as attributes: https://wordpress.stackexchange.com/questions/133472/allowing-shortcodes-inside-attributes

    Note: you would want to create your own shortcode that calls the wp-rss-retriever shortcode inside of it instead of editing the plugin itself.

    Plugin Author Travis

    (@tjtaylor)

    This does what you’re trying to do:

    
    // [custom_rss]
    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="10" excerpt="50" read_more="true" credits="true" new_window="true" thumbnail="200" cache="7200"]');
    }
    • This reply was modified 5 years, 7 months ago by Travis.
    Thread Starter wordmax

    (@wordmax)

    Awesome, thanks!

    What’s the recommended way to change the CSS styles for the titles, excerpts, etc?

    Plugin Author Travis

    (@tjtaylor)

    You can target the elements via CSS selectors .wp_rss_retriever_title, .wp_rss_retriever_container, .wp_rss_retriever_image. You may need to include the !important flag depending on how you use CSS specificity

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘How to make custom RSS feed using the post title?’ is closed to new replies.