1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Cool Tricks and Hacks for Wordpress

Discussion in 'Blogging' started by Endire, Apr 9, 2013.

  1. Endire

    Endire Elite Member Premium Member

    Joined:
    Mar 27, 2012
    Messages:
    1,756
    Likes Received:
    1,061
    Gender:
    Male
    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 http://www.color-hex.com/

    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.

    Code:
    #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?
     
    • Thanks Thanks x 17
  2. masister

    masister Newbie

    Joined:
    Apr 9, 2013
    Messages:
    17
    Likes Received:
    2
    niceee :)
     
    • Thanks Thanks x 1
  3. sashablack

    sashablack Elite Member

    Joined:
    Jan 8, 2010
    Messages:
    3,697
    Likes Received:
    2,050
    Gender:
    Male
    nice share dude :)
     
    • Thanks Thanks x 1
  4. innozemec

    innozemec Jr. VIP Jr. VIP

    Joined:
    Aug 19, 2011
    Messages:
    5,290
    Likes Received:
    1,799
    Location:
    www.Indexification.com
    Home Page:
  5. tompots

    tompots Elite Member Premium Member

    Joined:
    Dec 11, 2011
    Messages:
    4,352
    Likes Received:
    3,955
    Gender:
    Male
    Occupation:
    Full Time Bot Developer
    Location:
    Professional Botters
    Home Page:
  6. lovetospooge

    lovetospooge Junior Member

    Joined:
    Jul 24, 2011
    Messages:
    171
    Likes Received:
    91
    Location:
    Cape Town, ZA
    Will implement a few of them. Great share :)
     
    • Thanks Thanks x 1
  7. adamache

    adamache BANNED BANNED

    Joined:
    Mar 25, 2013
    Messages:
    45
    Likes Received:
    11
    i like the custom login page template
     
    • Thanks Thanks x 1
  8. AR!ZONA

    AR!ZONA Regular Member

    Joined:
    Mar 20, 2012
    Messages:
    400
    Likes Received:
    391
    Location:
    Cactus Island
    Yea, that would be great for when yo hand the site over to clients!
     
    • Thanks Thanks x 1
  9. service hub

    service hub BANNED BANNED

    Joined:
    Dec 16, 2012
    Messages:
    363
    Likes Received:
    69
    Good share i had got some idea by reading this !
     
    • Thanks Thanks x 1
  10. edgematch

    edgematch Elite Member

    Joined:
    May 24, 2010
    Messages:
    2,539
    Likes Received:
    1,949
    Occupation:
    You can never guess!
    Location:
    :noitacoL
    Thanks. I will surely use some of them.
     
    • Thanks Thanks x 1
  11. Harishwar

    Harishwar Newbie

    Joined:
    Mar 6, 2013
    Messages:
    17
    Likes Received:
    3
    Good Post, Thanks for the Random Post Page Code.
     
    • Thanks Thanks x 1
  12. Zhope

    Zhope Newbie

    Joined:
    Oct 30, 2012
    Messages:
    17
    Likes Received:
    2
    very nice post
    i liked the author comment one
    thanks given :)
     
    • Thanks Thanks x 1
  13. Moosey

    Moosey Senior Member

    Joined:
    Dec 5, 2011
    Messages:
    1,043
    Likes Received:
    747
    Thank you for the share, takes away the hassle of having to install a different plugin for each task.
     
    • Thanks Thanks x 1
  14. Rumborak

    Rumborak Junior Member

    Joined:
    Nov 13, 2010
    Messages:
    148
    Likes Received:
    102
    Location:
    Dagoba System
    The custom log-in is pretty useful, thanks mate!
     
    • Thanks Thanks x 1
  15. leonscion

    leonscion Registered Member

    Joined:
    Apr 4, 2013
    Messages:
    52
    Likes Received:
    7
    THanks for the hacks. I will try my best to implement them into my wordpress.
     
    • Thanks Thanks x 1
  16. Technician

    Technician Junior Member

    Joined:
    Aug 18, 2010
    Messages:
    154
    Likes Received:
    12
    Very nice indeed. A lot of nice little tricks in there that can really make a blog pop. This is exactly the kind of post that people should be directed to when they ask about what they can do to make their blog stand out/make it profitable. Thanks for taking the time and the effort to post this, it's very helpful.
     
  17. Moxxy

    Moxxy Newbie

    Joined:
    Nov 30, 2012
    Messages:
    15
    Likes Received:
    8
    Sweet! Thanks!!
     
  18. SEOSHNIK

    SEOSHNIK Newbie

    Joined:
    May 25, 2010
    Messages:
    33
    Likes Received:
    3
    Thanks for the great tutorials!