Code not executed in a widget but ok when hard coded (6 posts)

  1. ouranos2
    Posted 6 years ago #

    I want to display subcategories of current category in a widget. So i tested exec-php and "exec-php / hello world" works fine.

    The code I'm using (see below) works fine when hard-coded in the sidebar, but doesn't display anything when i put it in a text widget.

    I tried with no other active plugin, same result ...

    You can see the two widgets and the hard-coded result here, at the bottom of the sidebar.

    Any idea ? Thanks.

    if (is_category()) {
      $this_category = get_category($cat);
      if (get_category_children($this_category->cat_ID) != "") {
  2. ouranos2
    Posted 6 years ago #

    Thanks Otto, but i already tried it, and a bunch of other php plugins. I will try once more with php-code-widget, though, and after that i will bother you with the same problem on your plugin page ... ;)


  3. ouranos2
    Posted 6 years ago #

    So, i tried again with php-code-widget. You can see the result at the same url : http://www.xarax.fr/wpfsc4/rubrique/democratisation-de-la-science/
    A php-code-widget "hello world", no problem so far. But the code i try to execute (see above) give no result. Same code hard-coded in the sidebar, no problem (bottom of the sidebar).

    Any idea from the Tech Ninja would be a great help ... ;)

  4. Your code doesn't have $cat defined. Where is that variable supposed to be coming from?

  5. ouranos2
    Posted 6 years ago #

    Sorry Otto, but I've got no php skill at all ... The variable is the current category in the url ? What i don't understand is why this exact same code works fine when i don't use any plugin (when the code is in the sidebar template) and why it doesn't work with a "php-widget-plugin" ?

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Exec-PHP
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic