5 Most Popular WordPress Tricks to use in version 4.5 and above

1. How to Create Random Post using WordPress Page

WordPress has more features when compared to other CMS. Here you can see one of the feature, that is used to create random post using the wordpress page. To read random articles you need to use the below code in a page that will allow you to  display random post whenever you visit the page.

query_posts(array('orderby' => 'rand', 'showposts' => 5));
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; ?>

This code will display you at least 5 articles in the page where you have displayed the PHP script. If you want to change the count to 2 or 3 then change the number “5” in the first line of the code to the number of post you need.

2. How to Add Google Analytics Code

Google Analytics is used to make a complete analysis of your site regarding the page views, clicks, visited country, devices etc. There a more options available in Google Analytics, using this result you can make your website more popular.

To add the Google Analytics, paste the following code in the “functions.php” file. After adding the code, it will automatically load the code in every footer page of your website.

add_action('wp_footer', 'add_googleanalytics');
function add_googleanalytics() { ?>
//Paste Google Analytics code
<?php } ?>

3. How to create resourceful 404 web page

To create a 404 web page in your wordpress, you need to mention some of the elements in a image like “Sorry”, “Under Maintenance”, “Will Get you back Shortly” etc. These kind of words will allow the users to revisit your website. Please, Sorry.. these kind of words will make users not to get anger or irritation.

4. How to improve typography in WordPress

In order to improve typography in WordPress, you can use a plugin called WP-Typography that will allow you to use the shortcuts for your punctuation and mathematical calculations which you put in your post.

Use this plugin and improve your typography in WordPress.

5. How to Add Custom Logo in Dashboard

In WordPress, you can add custom logo in your dashboard, so that you authors can feel the working experience in your website and it can also act as marketing trrick for your authors for your website.

add_action('admin_head', 'my_custom_logo');

function my_custom_logo() {
echo '
<style type="text/css">
#header-logo { background-image: url('.get_bloginfo('template_directory').'/images/custom-logo.gif) !important; }

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *