Poiesis Web Development

WordPressIn our last post we looked at hard coding your Google Adsense code to the loop in your index page. That will display Adsense on your home page and your archive pages. In this post we’ll look at creating a short code to place adsense in your posts on the fly without having to copy and paste your Adsense code. This requires us to add a function and a short code to the functions.php page of your theme.

Don’t worry, it’s not complicated at all. Just open your functions.php file in your theme’s folder and scroll to the bottom of the file. Here we’ll add the following code:

Continue reading “Adding a short code for Adsense insertion into your post” »

Tags: , ,

WordPressThere are a number of plugins you can use to add Google Adsense to your blog. Unfortunately, most of them have very little flexibility when it comes to the positioning of the ads. But fret not; there are a few hacks you can use to hard code the Adsense code to your blog. These hacks are applied to your theme.

The obvious place to have your Adsense is on your home page. In this post, we’ll look at inserting Adsense on your hope page. This would be in the loop in the index.php page. As you can guess, it will also be applied to other pages that use the loop, namely the various archives pages.

Let’s begin:

Open the index.php file of your theme and find the line <?php if ( have_posts() ) : ?> and add the following just before this line:

<?php
    $postnum = 1;
    $showadsense1 = n1;
    $showadsense2 = n2;
    $showadsense3 = n3;
?>

Just change n1, n2, and n3 to whatever posts you want the Adsense to appear after. So if you want it to appear after the 1st, 4th and 8th posts, just change it to 1, 4 and 8 respectively. Also, if you only want one Adsense unit in the loop, discard the lines: $showadsense2 = n2; and $showadsense3 = n3;.

Continue reading “Adding Adsense code to your blog” »

Tags: , , , ,

PHPMost WordPress themes have a copyright notice in the footer like the one we use: © Copyright 2003-2009 Poiesis Web Development. The copyright notice is fine for the first year, however, it needs to be updated every January, or your blog begins to look old and unprofessional. Maybe you’re growing weary of having to open the footer.php file to manually change the copyright year every January. Well, since WordPress is based on PHP, there’s a simple solution called the PHP date() function.

The date() function

The PHP date() function returns the current timestamp as a string that can be formatted to displayed particular elements of the timestamp, such as the day, the time, the year, etc. In this post we’re interested in the year and there are two PHP format for year: 'Y', which represents the full year, as in 2009, and 'y', which represents the last two digits of the year, as in 09. The format that we use in the four digit format ('Y').

Continue reading “Automatically Changing the Copyright Year in Your Footer” »

Tags: ,

Display RSS FeedRSS feeds are quite handy. You subscribe to a feed that can be read using an RSS reader, such as Google Reader; and they can be displayed in e-mail applications, such as Microsoft Outlook 2007 and later. But they can also be displayed on your blog!

How? You might ask? Well, it’s really simple. Just copy the following code and include it in the .php file of the page in your WordPress theme where you want the RSS feed to be displayed.

<?php include_once(ABSPATH . WPINC . '/rss.php');
wp_rss('http://feeds.feedburner.com/PoiesisWebDev', 3); ?>

This could be your theme’s sidebar, footer or a page template.

Continue reading “Displaying an External RSS Feed on Your Blog” »

Tags: ,

WordPressWe’ve recently upgraded our WordPress installation to WordPress 2.8 and realized just why I hate upgrading WordPress! On the 2.7.1 version the NEXT POSTS / PREVIOUS POSTS link at the bottom of the page worked perfectly, but after the upgrade it pointed erroneously to http://www.poiesis.co.za/index.php/Index.php/page/2/. I’m sure you can see the problem there: the double index.php in the URL! The solution to the problem is simple: open the formatting.php in wp-includes and add the following line in the function clean_url after the if ('' == $url) return $url; statement:

$url = str_replace('index.php/Index.php','index.php',$url);

Continue reading “Double index.php problem” »

Tags: ,

WordPressWe’ve received a few queries about the next/previous link in our WordPress themes from people wanting to know how to implement it in their themes. Well, the answer is simply insert the posts_nav_link() template tag into the php files of your theme that has the if ( have_posts() ) : while ( have_posts() ) loop. These files include index.php and archive.php. When you use the posts_nav_link() tag the next/previous links are generated automatically when required. However, the tag only works for pages of posts.

Continue reading “Next-Previous link not showing?” »

Tags: ,

May
27

CSS Stylesheets

CSSA cascading style sheet or CSS allows you to separate the presentation and content of your web sites, with your content contained in your (X)HTML files and your presentation defined in a CSS. The CSS can be an internal stylesheet defined in the head element of your html file, an external file referenced in the head element, or an inline style defined in an html element.

The Internal Stylesheet

If you use a CSS style in the header element you need to enclose it in a style element, as in:

<head>
<title>Your Page Title<title>
<style type="text/css">
CSS Content
</style>
</head>

Continue reading “CSS Stylesheets” »

Tags: , , , , , ,

CSSNow that our first WordPress Theme is done, we can start discussing designing your own site. When designing your site, the first thing you need to consider your layout and your background. With CSS these can be two separate things with your background being your page and your layout being your divs that you place and position over the page. Background properties can also be applied to your divs, but then they will be restricted to the divs that contain them. In this tutorial we’ll look at the background properties that can go in the body element of your stylesheet.css file.

Backgrounds Colors

Continue reading “CSS Background Properties” »

Tags: , , , , ,

Our First WordPress Theme

Simply Smart WordPress ThemeOur first WordPress theme, which we’re calling the Simply Smart, is coming along nicely. It’s a dark red, two-column theme with a fixed width of 1024 pixels designed for an automotive weblogs and is sponsored by custom-car.us. It uses a solid background, with an automotive image in the header (of a Smart Car Roadster, hence the “Smart” bit in the name), and a simple (hence the “Simple” bit in the name) two-column layout with a widget-ready side column on the right. It also supports an Author’s Archive page, which is ideal for blogs with multiple authors, like this blog (I guess we’ll be implementing it here too then).

Continue reading “Simply Smart” »

Tags: ,

I Need A Job!There’s nothing like a recession to get you back on track … Many years ago I was tasked with creating and maintaining a website for our department at campus. The result was my first website (co-incidentally, it was a table-based layout, the year being 1999 and Y2K being all the rage). From there the idea of earning some income by doing some web development on the side emerged and poiesis.co.za was registered. Unfortunately, or fortunately, a lucrative job intervened and poiesis.co.za was put on the backburner. It became a small personal website for a while and then a personal collection of bookmarks. In the mean time I developed a couple of content websites as a hobby.

Continue reading “There’s nothing like a recession!” »

Tags: ,