Cool Tricks and Hacks for Wordpress

1 replies
  • WEB DESIGN
  • |
It's common knowledge among the online community that Wordpress is a very popular CMS. I also see many people favoring it on this forum so I thought I would put together some tricks that I have gathered from around the web that have worked for me.

Highlight Blog Author Comments on Your Own Website

These little hacks will make it so any comments that you post on your blog will be highlighted in a color of your choosing. The exact configuration of code may vary depending on what kind of theme you have installed but this should work for you or at least point you in the right direction.

Look for the CSS that is applied to your author comments. If you are using the default Wordpress commenting system you will be looking for a class like .authcomment. Once you have found it, apply a hex color of your choice. You can find examples of hex colors here Color Hex Color Codes

Your CSS should look something like this,

Code:
.authcomment 
{
background-color: #YOURHEXCOLOR;
}
You will also want to define a class in comments.php like this,

Code:
<?php
$comment_class = (YOURUSERID == $comment->user_id) ? 'comment-admin' : 'comment';
?>
Editing a Custom 404 Error Page

Many Wordpress templates come with their own 404 error pages. They are typically named 404.php. You can find this file in your theme folder. You should also be able to find it in your WP backend.

To modify your existing 404 page,

1. Log into your backend.
2. Open your theme editor or click appearance then editor
3. Look for 404.php

Open and edit the template by inserting your own text or code to display.

you should see code like this,

Code:
<?php get_header(); ?>
   <div id="content" class="narrowcolumn">
     <h2 class="center">Insert some clever or funny text here that users can see when they hit a URL that does not have a page associated with it.</h2>
   </div>
<?php get_sidebar(); ?>
<?php get_footer(); ?>
Make All External Links Open in New Window by Default

To do this you will be searching for a file called link.htm however it may vary based on your theme. It can typically be found in the wp-includes directory and specifically at wp-includes/js/tinymce/themes/advanced/link.htm.

All you have to do is switch the order of the two lines of code below:

From

Code:
<option value="_self">{$lang_insert_link_target_same}</option>
<option value="_blank">{$lang_insert_link_target_blank}</option>

To

Code:
<option value="_blank">{$lang_insert_link_target_blank}</option>
<option value="_self">{$lang_insert_link_target_same}</option>
Now external links pasted into your posts should open in a new window.

Make A Custom Login Page for WP Backend

This is a nice little touch to brand your website even if you are the only one to see the login page. Depending on your version of Wordpress, you will be looking for a file called login.css. In that file you will be looking for background-color and h1 background image properties. The image will be located in your images folder and may be named logo-login.png or something similar.

You can also change the default link on the page from wordpress.org to our home page. If you want to change the login form, look for a hook like "form" somewhere in login.css. You can change anything you want from the fonts, input fields, links, etc.

Style Individual Posts

This hack allows you to style individual posts apart from the rest of the styling on your Wordpress blog. You might want to make one post stand out from the rest such as announcements or maybe a post that contains a special ofer. You will be using this function:

Code:
<?php the_ID(); ?>
This function displays the numeric ID of the current post. It can also be used as a unique anchor identifier for each post allowing you to style posts individually if you want to. The identifier might look like this inside of a post.

Code:
<h3 id="post-<?php the_ID(); ?>">Your Post Title</h3>
Entire posts are typically contained within divs and use of a div plus the function might look like this.

Code:
<div class="post" id="-<?php the_ID(); ?>">post headline, post body, etc</div>
Find your specific post ID and insert style properties in style.css or applicable style sheet associated with your theme. It would look something like this.

#post-84
{
background-color: #fff;
Font: 'tahoma', Arial;
}

Create a Page that Displays a Random Post

You will need to create a custom page in Wordpress and you can do this pretty easily from your back end interface. Just create a page and install the following code on it.

Code:
<?php
query_posts(array('orderby' => 'rand', 'showposts' => 1));
if (have_posts()) :
while (have_posts()) : the_post(); ?>

<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>

<?php the_content(); ?>

<?php endwhile;
endif; ?>
It is a loop that runs a query to tell Wordpress to show random posts. Notice that the number attributed to 'showposts' is set to one. If you want to show more than one post on the page each time it is refreshed, increase that number.

I hope you can find some use out of these hacks. Are there any special tricks that you use with your Wordpress blog that you would like to share?
#cool #hacks #tricks #wordpress

Trending Topics