cymeradwyo.net  
 

Posts Tagged ‘Wordpress’

How to add a lightbox form to WordPress

Thursday, February 11th, 2010

Here are the steps that I took to create the lightbox subscription form used on this site:

1. Download “Lightbox gone Wild” from this page.

2. Unpack the following files and save them to the “lightbox” directory on your site:

scripts\lightbox.js
scripts\prototype.js
css\lightbox.css

3. Save the HTML code for the lightbox as a file in the lightbox directory, eg. as form.html

4. To make the lightbox load automatically, make the changes listed on this page, but don’t add the last line of HTML to anything just yet.

5. Return to the Lightbox gone Wild site and search for a comment from “preaxz”.  Make the changes listed, so that the lightbox disappears when you press Escape or click in the shadowed area.

6. Create the following files within your WordPress theme directory:

– lightbox-cookies.php –

<?php
$lightboxcookie = $_COOKIE["lightbox"];
setcookie ("lightbox","1",pow(2,31)-1,"/");   // never expire
?>

– lightbox-header.php –

<!-- CSS -->
<link rel="stylesheet" href="/lightbox/css/lightbox.css" media="screen,projection"
type="text/css" />

<!-- JavaScript -->
<script type="text/javascript" src="/lightbox/scripts/prototype.js"></script>
<script type="text/javascript" src="/lightbox/scripts/lightbox.js"></script>

– lightbox-activate.php –

<?php
if ($lightboxcookie != "1")
{
echo "<input class=\"lbOn\" id=\"lbOnAuto\" type=\"hidden\"
value=\"/lightbox/form.html\">";
};
?>

7. Within the WordPress theme file header.php, add the following lines:

On the very first line (yes, before the DocType!) add:

<?php include "lightbox-cookies.php"; ?>

Before the </HEAD> tag add:

<?php include "lightbox-header.php"; ?>

After the <BODY> tag add:

<?php include "lightbox-activate.php"; ?>

8. Now upload the 4 files in the theme directory and the lightbox directory to your site!

Bookmark and Share


How many archives should I show?

Thursday, January 7th, 2010

If you’ve been blogging for some time, then your archive list will be getting quite long.  I’ve been having that problem on some blogs, as the list of months in the archives was getting longer than the rest of the sidebar put together.

So I started wondering about how I could improve the situation.  I’ve come up with two possible solutions:

- use yearly archives instead of monthly ones

- limit the number of listed months

For blogs that have been going for a number of years, the yearly option is not bad, as long as the posts can still be found without going through too many pages.  I solve that using tag clouds or category lists.

But for most of my blogs, I’ve gone for the limited month option, and have set the limit to 12.

To do this, I’ve edited the sidebar.php and changed the call to wp_get_archives to

wp_get_archives(‘type=monthly&limit=12′);

or

wp_get_archives(‘type=yearly’);

Which do you think is the better option?  Of is there an even better way?

Bookmark and Share


Keeping the sidebar visible in WordPress

Wednesday, January 6th, 2010

One of the default settings in WordPress is for sidebar on the right-hand side only to be visible when you enter the site from the start page, but not if you are on an individual post.

This makes it rather difficult to add a newsletter registration box there, if you want it to appear on every page, and also means that other important items such as the Feedburner icon are not always visible.

So I will be going through my blogs and making sure that the sidebar is visible at all times.

To do this, I need to edit the file single.php in the theme.  I then turn the content part from a widecolumn into a narrowcolumn.   Finally, at the end of the file I need to add the get_sidebar() function.

I know that some of my blog themes are already set to do this, but I will be going through them all to make sure.  I’ve made a start with this one, so you should definitely see the newsletter box on the right-hand side.  Have you signed up yet?

Bookmark and Share