• I am using Polylang on Local developed wordpress website. I am trying to create a shortcode and later invoke it for Polylang flags with slugs in Neve theme header.

    This is my code:

    <?php
    	function polylang_shortcode() {
    		ob_start();		 
    pll_the_languages(array(‘show_flags’=>1,’show_names’=>1,‘display_names_as’ => ‘slug’));
    		$flags = ob_get_clean();
    		return $flags;
    }
    
    if (function_exists('pll_the_languages'))
    {
    add_shortcode(‘polylang’, ‘polylang_shortcode’);
    };
    ?>

    I invoke it with [polylang], but it does nothing but print exact string, “[polylang]”.

    Does anyone know what to do?

Viewing 3 replies - 1 through 3 (of 3 total)
  • This is not an Polylang related issue. add_shortcode() is a WordPress feature.

    Thread Starter supportneeded9

    (@supportneeded9)

    Is the Polylang part with pll_the_languages() well written then?

    Plus, Polylang says it should be invokable with shortcodes, so it should be related to Polylang as well.

    Also, would you mind pointing me to the right direction?

    The first issue you have so solve is, your shortcode is not executed. And this is still not Polylang related. Bring it up and running and afterwards you can check the Polylang function further.

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

The topic ‘PHP snippet not executing polylang’ is closed to new replies.