Daily Archives: July 10, 2013

html, url, http, php, widgets and all of that

In an attempt to improve the look of my blog, I decided to put a map on the sidebar. That should be easy, right?

Many thanks to Steve and Mona Liza for allowing me to pinch the idea, a photo of the map on the side of the RV, off their most excellent site The Lowe’s RV Adventures.

I’ve got a map too, I thought. I can do that. Several aborted attempts with the gallery widget and image widget produced nothing.

Mona Liza offered her help but not wanting to look the complete IT dunce, I thought I would try Googling how do I put a photo on the sidebar of my wordpress blog.

Well thanks to the helpful bods in the WordPress.org support forum for this but for the sake of your sanity please don’t bother to read any of the following in red. Skip to black.

Basically, in your functions.php file put in this:

function postimage() {
 // get the post meta info
  $key = "postimage";
  $id = get_the_ID();
  $custom = get_post_meta($id, $key, true);
  echo $custom;

Then in your sidebar.php file (or within a widget that you can enter in PHP code), put in:

$image = new WP_query ('showposts=1');
if(have_posts()) : while($image->have_posts()) : $image->the_post; ?>

<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php postimage(); ?></a>

<?php endwhile; endif; rewind_posts; ?>

where you want the image to appear.

There is absolutely no chance of me following any of that. Could you?

Then some clever lateral thinker called hhsleep, who is perhaps as programming-code-challenged as I am,  posted this easy solution:

“I figured it out.  Pretend you are doing a post.  Upload the image you want.  Then insert it in your post.  Copy the code and insert it in your text widget.”

Well thanks a bunch hh. That didn’t work either.

Then vtxyzzy posted:

First go to Admin->Media->Add New and upload the image you want. Once it is uploaded, click in the File URL box, hit CTRL-A CTRL-C to select and copy the URL.

Then go to Appearance->Widgets and drag the text widget into the sidebar.  In the text area, enter ‘<img src=”‘, then CTRL-V to paste in the URL of your picture. Type ‘” />’ to close the img tag. Click Save.

Sounded doable. Not too much code. Didn’t work. Not for me anyway.

Every post suggested using the text widget. Why would you do that when there is an image widget? C’mon. Tell me.

I had tried the image widget but discovered I was using the wrong url after having put the correct url in the text widget and just getting text.

Eventually I put the correct url in the image widget having spent HOURS on it. Or maybe many, many, many more minutes than I wanted to trying to put this map on the sidebar:

How did we miss that one?!!!
How did we miss that one?!!!

And who is going to appreciate all that effort? Nobody but me, but I think it looks amazing. Thank you again Mona Liza. I should have come to you first.