Forums

Excute php code from widget (5 posts)

  1. hiko
    Member
    Posted 2 years ago #

    Hi,

    I am new in word press.

    I have created widget from admin side and i want to execute following php
    code from widget

    <?php
    echo"hello";
    ?>
  2. hiko
    Member
    Posted 2 years ago #

    Hi,

    I have downloaded php code plugin

    when i create new widget and use code

    <?
    echo"hello";
    ?>

    it is giving following message

    echo "hello";
    ?>
  3. MichaelH
    Volunteer
    Posted 2 years ago #

    Consider downloading and installing Otto's PHP Code Widget.

  4. Otto
    Tech Ninja
    Posted 2 years ago #

    It has to start with <?php, not <?. Short forms are not supported.

  5. dflipse
    Member
    Posted 1 year ago #

    Hi, I also (think) I just want to execute a little bit of php code within a widget, and your widget seemed like the perfect thing.

    I'm trying to make a very simple thing, essentially a post counter saying "Now with 400 posts." Your plugin in combination with the wp_count_posts function seemed to be the perfect thing. I installed the plugin, added the Widget to the appropriate sidebar, and pasted the following in after my plain text-

    <?php
    $count_posts = wp_count_posts();
    ?>

    I thought that code would then return a number of posts, but it just leaves a blank space. I freely admit to being a relative novice, and feel like I'm missing something pretty obvious. Any help would be great. Thanks.

Topic Closed

This topic has been closed to new replies.

About this Topic