Home Forums Add-ons Options Page Options Page shortcode is not rendered corectly


Options Page shortcode is not rendered corectly

  • Hi guys, i have a an option page, inside option page i have a Group field called Cookies and inside the group, i have plenty “wysiwyg” fields here.
    In order to get my field i use it like this:

    $cookies = get_field('cookies', 'option');
     $cookies['fieldname'] //this is just a random name, but it;s just to load the field.

    inside this field i have a shortcode “[domain_host]” that shows the domain name the website is hosted on.

    function domain_host(){
        $host_name = $_SERVER['SERVER_NAME'];
        return $host_name;
    add_shortcode('domain_host', 'domain_host');

    the problem is when i use the shortcode inside a field i get the the shortcode as text, “[domain_host]”. Do you know why i experience this ?

  • the easy way to fix this is by simply apply the_content fileter.

    $cookies = get_field('cookies', 'option');
    $text = $cookies['fieldname'];
    echo apply_filters('the_content', $text);
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.