Cool Tricks and Hacks for Wordpress
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,
.authcomment { background-color: #YOURHEXCOLOR; }
<?php $comment_class = (YOURUSERID == $comment->user_id) ? 'comment-admin' : 'comment'; ?>
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,
<?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(); ?>
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
<option value="_self">{$lang_insert_link_target_same}</option> <option value="_blank">{$lang_insert_link_target_blank}</option>
To
<option value="_blank">{$lang_insert_link_target_blank}</option> <option value="_self">{$lang_insert_link_target_same}</option>
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:
<?php the_ID(); ?>
<h3 id="post-<?php the_ID(); ?>">Your Post Title</h3>
<div class="post" id="-<?php the_ID(); ?>">post headline, post body, etc</div>
#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.
<?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; ?>
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?
-
Istvan Horvath -
[ 1 ] Thanks
Signature{{ DiscussionBoard.errors[7954223].message }} -