PHP Code Widget
[resolved] PHP code not supported in the widget title (5 posts)

  1. ad4mlaz
    Posted 3 years ago #

    Hi, I'm trying to add PHP code in the widget title, but when I press save, the PHP code is removed.

    For example the widget title that I want to use is:
    More from <?php $category = get_the_category(); echo $category[0]->cat_name; ?>

    But when I hit Save, the title becomes:
    More from

    Is there any trick for allowing this to work?

    Thanks for your help.


  2. Samuel Wood (Otto)
    WordPress.org Tech Dude
    Plugin Author

    Posted 3 years ago #

    You do have to be an admin and/or have the unfiltered_html capability on the site. Otherwise it'll get filtered like everything else.

  3. Samuel Wood (Otto)
    WordPress.org Tech Dude
    Plugin Author

    Posted 3 years ago #

    Oh, I just saw that you are trying to put code in the TITLE. Missed that.

    Yes, the PHP Code Widget does not support PHP Code in the title.

  4. Ricky
    Posted 3 years ago #

    I know this is an old thread, but any way this plugin will support PHP code in the future? I decided to place <?php echo 'test'; ?> in the title and the entire site failed to load O.o luckily I was able to remove the widget entry from the backend and the site loaded. Scared me for a sec!

  5. nilanjanb
    Posted 2 years ago #

    the way I have done this - leave the title blank
    write code in the widget to display whatever you want

    Works for me :-)

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic