• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

RESOLVED php snippets not working in sidebars/header bars

scootz

New member
Messages
4
Likes
0
Points
1
#1
I trying to insert a php snippet into either the sidebars or header area. The code is super simple and is the content that goes into the snippet. I use [hello test="here"] as an example. Nothing done on the attribute. I just want it to print hello.

Code:
    <?php
        echo "hello";
The snippet doesn't get executed? Is this by design that php snippets don't get executed in sidebar/headers? Have any ideas?

*EDIT* I changed the widget from a custom html to just plain text and it is working as needed. This is partially solved.
 
Last edited:

Temyk

Developer & Support
Messages
1,129
Likes
42
Points
48
#2
Hi,

Do you add snippet shortcodes to the widget? If so, the widgets shortcodes work.

If the problem is not solved yet, send screenshots of snippet settings and the place where you insert it
 

Temyk

Developer & Support
Messages
1,129
Likes
42
Points
48
#3
Your problem is solved?
 

scootz

New member
Messages
4
Likes
0
Points
1
#4
Wow, I don't even remember posting this. custom short codes do not work while using custom html widget. It does work while using a plain text widget. See included images. The first image is of both html widget and text widget in the header sidebar. The top line is the custom html widget which doesn't work. The bottom line is a normal text widget which works. The second image shows the code for the snippet. I'm using the current versions (WP 5.2.2?/ Woody 2.2.7)

*edit* I was too strict with my nginx config. 403 on related woody scripts etc.
Also to note, the second image shows another bug. I've disabled all plugins except the woody plugin. Used one of the stock themes (seventeenth?) and it still shows limited width. I can only adjust up and down size of the textarea.
 

Attachments

Last edited:

Temyk

Developer & Support
Messages
1,129
Likes
42
Points
48
#5
Are we talking about HTML and text widgets or snippets?
 

Temyk

Developer & Support
Messages
1,129
Likes
42
Points
48
#7
By default in Wordpress, shortcodes are not allowed to be executed in a custom HTML widget.
To change this, create a php snippet with execution everywhere:
PHP:
add_filter( 'widget_text', 'do_shortcode' );
 

scootz

New member
Messages
4
Likes
0
Points
1
#8
That fixed it. Maybe some how you can add this add_filter to the docs or FAQS so others can find it that are running into the same situation. Thanks for the help :)