5 replies
I'm building a lot of Wordpress blogs quickly and I want to try and streamline some of the work. Is there a way to use variables within a text widget? Like for instance instead of writing:

"This blog was created on June 20, 2010 and is about Fuzzy Blue Widgets, please contact joesixpack@blahblahblah.c0m"

can I do

"This blog was created on [DATE] and is about [BLOGTITLE], please contact [CONTACTEMAIL]"

any way to do something like this?
#variables #wordpress
  • Profile picture of the author webatomic
    Thanks. I don't know much about PHP, but is it pretty self-explanatory to get it to do what I need it to do?
    {{ DiscussionBoard.errors[2243264].message }}
  • Profile picture of the author Amaroks
    you can also use the plugin widgetSamsarin PHP Widget -- Samsarin it allows you to add php in text widget , install that and get the php code from wordpress website
    {{ DiscussionBoard.errors[2243326].message }}
  • Profile picture of the author Istvan Horvath
    You don't really need to know PHP... although a familiarity with the WordPress online documentation (a.k.a. the Codex) might help to find the code snippets you are looking for.

    <rant>another question that should be posted in the WP support forum, not in a 'make money' forum...</rant>
    Signature

    {{ DiscussionBoard.errors[2243560].message }}
  • Here's one way to accomplish your example...

    1. For each new installation of Wordpress, create an empty text file named "install.txt" and upload it to the root Wordpress directory (where you find the index.php, wp-config.php, and version.txt files).

    2. Install the Exec-PHP plugin.

    3. Add the following PHP code to your Wordpress theme's "functions.php" file:

    Code:
    <?php function wpInstallDate() {
    	echo date('F d, Y',filemtime(ABSPATH.'install.txt'));
    }?>
    4. Insert the following code into a text widget and drag-and-drop it to a widgetized area:

    Code:
    "This blog was created on <?php wpInstallDate();?> and is about <?php bloginfo('name');?>, please contact <?php bloginfo('admin_email');?>"
    {{ DiscussionBoard.errors[2243908].message }}

Trending Topics