Problems With Wordpress

by kah22
8 replies
Hi guys I haven't used Wordpress Widgets before and I'm having a little difficulty with them, guidance would be appreciated.

I'm using the Wordpress Theme 'Branford Magazine' with the 'Nimbo Sidebar,' and I am trying to add the plugin 'Quotes-Collection,' so that I might add daily tips to my blog. I'm using Wordpress 2.8

The sidebar already contains information such as 'archive' an ad block, all the usual info you'd find on a standard sidebar.

My problem is this when I go to WP Admin » Appearance » Widgets, and drag the 'Random Quote' widget into the sidebar the quote shows OK but everything else disapears and quote is sitting, pretty as you like, right at the top of the sidebar. Where have I gone wrong? What to do?

I'm not stuck on using plugins or widgets in fact I had tried this bit of code which I picked up from Robert Plank HERE, which means I can put my tips anywhere I want, but it was showing up faulty.

Anyway here is the code:

Code placed in my sidebar.php
<li>
<h3>Random Tips</h3>
<?php require("tips.php"); ?>
<ul class="subnav">
</ul>
</li>

A text file called tips.txt containing something like
tip #1
tip#2
tip#3
and so on. Each tip on a new line.

And finally a file called tips.php with the following code
<?php

$hash = floor(time() / (60*60*24));
srand($hash);

$tips = array_map("trim", file("tips.txt"));

$tip = $tips[array_rand($tips)];
echo $tip;

?>

Unfortunately I get errors something like this:
Warning: file(tips.txt) [function.file]: failed to open stream: No such file or directory ..../mywebsite.com/public_html/wp-content/themes/branford with mimbo sidebar/tips.php on line 6

Warning: array_map() [function.array-map]: Argument #2 should be an array in .../mywebsite.com/public_html/wp-content/themes/branford with mimbo sidebar/tips.php on line 6

All the code is placed in the Branford Magazine directory.

Any suggestions on the plugin, any suggestions on the code above. I actually prefer doing the job by code as I feel I have more control over what happens.

Kevin
#problems #wordpress
  • Profile picture of the author radio
    once you add the widget - what happens if you add more widgets to the sidebar? like add the recent posts widget, pages widget, etc AFTER you add the quotes widget. Remove that code from your sidebar - if they are providing a widget it is probably going to work ALOT better... even though you're having problems now.
    {{ DiscussionBoard.errors[955048].message }}
  • Profile picture of the author SteveJohnson
    Two things:

    When a sidebar is coded for a theme, most times there is some 'default content' coded in that disappears as soon as you put a widget into the sidebar. 99% sure in this case that's what's happening.

    As far as the error message, it's telling you that it couldn't load the 'tips.txt' file - either the file isn't there, it's corrupted, or the file path is wrong. The tips.txt file must be in the same directory as the tips.php file.

    The second error is related to the first - PHP is trying to operate on an array that doesn't exist yet because it couldn't load the tips.txt file.
    Signature

    The 2nd Amendment, 1789 - The Original Homeland Security.

    Gun control means never having to say, "I missed you."

    {{ DiscussionBoard.errors[955091].message }}
    • Profile picture of the author Karen Blundell
      Yes, Steve is right..what you can do is move down the php code that makes the widgets appear..the code will look similar to this:
      Code:
      <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
      just cut it and paste in further down after all the stuff that exists so that you can then add your widgets and the existing stuff won't be removed.
      Signature
      ---------------
      {{ DiscussionBoard.errors[955563].message }}
      • Profile picture of the author netkid
        For whatever it's worth, if you are still having problems, you might want to think of "retro-grading" to Wordpress 2.7.1. (previous version than 2.8)

        I did a "retro" twice already on two different blogs and my plugins work like a charm again. Of course you have to back up your blog data to reinsert that old data when you do the retro.

        Anytime Wordpress hits us with an upgrade (too many, too soon I might add) quite often plugins, are rendered useless.

        I used to do WP upgrades after having a blog up for several months and then I find out my key plugins don't work with the upgrade.

        A lot of times plugins are not upgraded themselves properly to handle the new version of Wordpress.

        And of course you need to wait a little until the "bugs" are worked out of beta releases or even the full out version of Wordpress programs.

        Regards,
        Bruce
        {{ DiscussionBoard.errors[956012].message }}
        • Profile picture of the author The Pension Guy
          Originally Posted by netkid View Post

          For whatever it's worth, if you are still having problems, you might want to think of "retro-grading" to Wordpress 2.7.1. (previous version than 2.8)
          Hi Bruce,

          That won't help the OP: whatever is coded in the sidebar of a theme will be replaced by widgets even if you activate only one... and it happened like that ever since the widgets were introduced in WP, way before2.7.1. Which means "downgrading" is not a solution.

          Actually, there is no need for solution, since there is no problem. What the OP described that's the expected behaviour of the widgetized sidebar.
          Signature

          {{ DiscussionBoard.errors[956025].message }}
  • Profile picture of the author tommen
    Some plugins stop working when you upgrade Wordpress to a newer version.I still use 2.7.1 because I have some plugins that are not compatible with 2.8.
    Signature
    {{ DiscussionBoard.errors[956325].message }}
  • Profile picture of the author Katie Rich
    Is this a free wordpress blog, hosted by them, or one with your domain name hosted by you? I have had problems with widgets on the free ones, but my own hosted ones seem to work ok.
    {{ DiscussionBoard.errors[956410].message }}
    • Profile picture of the author kah22
      No, it is hosted by me. My own domain and all that.

      Kevin
      {{ DiscussionBoard.errors[958915].message }}

Trending Topics