Fixing WordPress Permalinks

Today I was working on a client’s WordPress site who needed permalinks enabled so that the post name would show up in the address bar which is much better for SEO purposes. I enabled permalinks with the post name option in the admin of WordPress, but got page not found errors when visiting the posts, so I had to find the solution. Here is what I did.

I read online that mod_rewrite was probably the culprit. Before assuming this, you should make sure your .htaccess file is working properly and is writable from WordPress before setting permalinks up. You can simply make sure the file exists and set permissions to 777, enable permalinks, then set your permissions back as they were to make your file secure once again. If that doesn’t do it, then check your mod_rewrite using the following procedure:

  1. make a info.php file with only this for content: “<?php phpinfo(); ?>” and save it as info.php. Upload to your root directory and go to your domain name/info.php and search for the text “mod_rewrite” if you find it in the php info file, then your mod_rewrite is enabled. If not, then enable it.
  2. To enable mod_rewrite, try the command line command: sudo a2enmod rewrite

If mod_rewite was enabled then something else is wrong. Check your etc/httpd/conf/httpd.conf file. It should have the following in it:

AllowOverride All

Basically, you’ll be adding All insted of None to AllowOverride, you do not want to edit the main directory configuration, you want to edit the one that looks like this:

<Directory “/var/www/html”>

Not:

<Directory />

Then restart Apache with:

sudo service httpd restart

from the command line.

Now, if you are using WordPress and trying to enable Permalinks as I was, next, go to your wp-admin page and go to settings/permalinks and change from default to post-name and click the save button to save the changes and try again. If you did this before making mod_rewrite fixes, you may need to change back to default, save, and then change to post-name again and save one last time for the settings to work.

Good Luck!

Adding Links to Other Blog Pages in a WordPress Post

Many times I have wanted to reference and link to another post in my blog from within a post or a page. This short tutorial will show you how to link to another post from within a post on any WordPress blog. I will show you how to create links to posts, pages and even categories. If you are using permalinks, you can simply use the permalink, so this guide is for those of us that don’t always use permalinks.

For example, CLICK HERE TO SEE ALL OF MY WORDPRESS POSTS on this blog! and then look below to see how I did this.

First of all, I created the above link using the visual view that most people are most familiar with when using the WYSIWYG editor in the WordPress admin, however, after a quick demonstration on how I did it, the rest of this tutorial will be based on how to add links using the Text view tab in the WYSIWYG editor, just because it is easier to explain from a coder’s perspective.

To create the link to my WordPress category, I typed the text “CLICK HERE TO SEE….” then highlighted that text and clicked on the link icon in the editor’s tool bar. In the link dialog box that pops up, I replaced the default “http://” with just “index.php cat=48”, ,checked the box to make the link open in a new window and saved it. That’s it!

Getting the Category ID

you need the category ID for the link. The id for my blog’s WordPress category was 48 in the above example as you can see. To get it, go to your WordPress admin area and go to posts/categories then hover over the category title and you will see a number in your browsers info bar which is at the bottom left of the webpages in Firefox and most other browsers. Sometimes you might have to activate the info bar from your browser/settings dialog if you don’t see anything when hovering over links. The ID for categories will be right after the text that reads “tag_ID=” in the info bar when hovering over the category name in the edit category page.

 

Linking Without Permalinks

If you’re not using Permalinks, here is how to link to pages, posts, and categories:

*Using the number values found in the ID column of the Posts, Categories, and Pages Administration, you can create links as follows.

Posts

To link to a Post, find the ID of the target post on the Posts administration panel, and insert it in place of the ‘123’ in this link:

<a href="index.php?p=123">Post Title</a>

Categories

To link to a Category, find the ID of the target Category on the Categories administration panel, and insert it in place of the ‘7’ in this link:

<a href="index.php?cat=7">Category Title</a>

Pages

To link to a Page, find the ID of the target Page on the Pages administration panel, and insert it in place of the ’42’ in this link:

<a href="index.php?page_id=42">Page title</a>

*information from the asteric to here was taken from http://codex.wordpress.org/Linking_Posts_Pages_and_Categories

Get Rid of Top Margin on Custom WordPress Themes

I found out from experience and from browsing the internet that a lot of people are having issues with a mysterious 28px margin appearing at the top of their blog when developing a custom theme or a page template for an existing theme. This frivolous bug has the potential for people to start looking for other unlimited wordpress hosting websites to try to change their current webhosting wordpress website, and assimilate if that does the trick.

The Problem

The problem is that a built-in core WordPress function inserts an inline style into the head of your webpage with a top-margin set to 28 pix.

The Reason

The reason for the 28px top margin is to make room for the WordPress top admin bar, so you may have noticed that this margin is only there if you are logged in.

The Cause

the cause of the inline style is the wp_head function. It happens most of the time when you do not call the wp_footer function at the bottom of the HTML markup, just before the closing body tag.

The Solution

Therefore, the most common solution to make this go away, is to simply make sure to include the wp_footer function in your theme’s files just before the closing body tag. It can be inserted in either the page.php file or the footer.php file. It can also be inserted in any other page template file as long as it is directly before the ending body tag.