We're merging with GenerateBlocks! Learn more here.

[Resolved] Shortcode problem

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Shortcode problem

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #35939

    Hi,
    i have installed wp show post pro in a multilingual site. I have set up several pages with different aggregators showing groups of posts. I have implemented the agregators with this shortcode [wp_show_posts id=”9905″ settings=”taxonomy=post_tag&tax_term=TERM_NAME”].

    1. The first problem is that when I save inside the shortcode other characters are inserted, specifically “$amp;”.
    2. The second and most important problem is that aggregators work well in the main language (Italian IT) but break in all other languages.

    You will find below two example pages and the data of my site. Can you give me a hand?

    Many thanks.

    Beniamino

    EXAMPLE OF PAGES:
    IT: https://www.enigmap.net/cosa-fare-ad-halloween/ (it works)
    PT-PT: https://www.enigmap.net/pt-pt/ideias-para-halloween/ (not works)

    WORDPRESS SITE
    THEME: generatepress
    MULTILINGUAL MODULE: wpml

    #35962
    elvin
    Moderator

    Hi there,

    That’s WordPress escaping shortcode characters. We can do a workaround using filters.

    First, you must edit the plugin’s code on file wp-show-posts.php . https://github.com/tomusborne/wp-show-posts/commit/286caf1164db8b6b6f38b85d3a011b519a27f4de
    (Alternatively, you can use the latest beta – https://wpshowposts.com/wp-show-posts-1-2-0/)

    You then do a PHP filter like this example:

    add_filter( 'wp_show_posts_shortcode_args', function( $args, $settings ) {
        if(1234 === (int)$settings['list_id']){
    	$args['tax_query'] = array(
    			'relation' => 'OR',
    			array(
    				'taxonomy' => 'post_tag',
    				'field'    => 'slug',
    				'terms'    => 'your category/tag slug here',
    			),
        	);
      }
      return $args;
    }, 15, 2 );

    You then replace 1234 with the WPSP list ID and replace your category/tag slug here with the post tag term’s slug.

    You then unset the attributes of the shortcode, putting back the base. Example: [wp_show_posts id="9905"]

    #36009

    Hi,
    many thanks for the quick response.
    I think for now I will use the classic embed method of shortcodes. I will create different lists for each aggregator and insert the shortocodes without using the setting parameter.
    Many thanks.
    Beniamino

    #36015
    elvin
    Moderator

    No problem. 😀

Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.