QUICK TIP - WordPress tricks – The most useful tricks you should know

0 1,236,174
:6of8
1
2
3
4
5
6
7
8
Most Useful .htaccess Tricks for WordPress | A&H Business Technology
Related posts

Source: Hendry Lee (404 link removed)

Display the Total Number of Users for Your Blog 

Here is a tasty little snippet from WP Recipes that will enable you to display the total number of users for your WordPress-powered blog. All you need to do is place the following code in your theme file(s) where you would like to display your total number of users:

Automatically Insert Content into Your WordPress Post Editor 

Here is a nice way to automatically insert some custom content into your post editor. This makes it easy to add repetitive content to your posts while retaining the ability to make changes before publishing. To try it out, add the following code to your functions.php file:

This code will display a message thanking people for their generous attention, but you can easily edit the message to display whatever content (text/markup) that you wish. After configuring your message, open your WordPress text editor to see the automatically inserted content.

How to Prevent Duplicate Content 

Unless you’re using excerpts for non-single page views, your post content is being displayed in your single pages, date-based archives, category archive, tags archives, author archives, and so on. From an SEO perspective, this “duplicate” content may be detrimental to your search-engine rankings.

To prevent duplicate content, we can conditionally display one of two <meta> tags depending on the type of page being displayed. Pages that we want to have indexed in the search engines will display a “meta-index” tag, while duplicate pages will display a “meta-noindex” tag.

To do this, simply add the following code to the <head> section of your theme’s header.php file:

Once in place, this code effectively stops search engines from indexing all types of pages except for single-post, page-page, category-archive, and the first two index pages. These are considered by many to be the most effective pages to have indexed, but feel free to add or remove anything you see fit to customize the technique.

Source: AH Business Technology

Conditionally Display Full Posts or Excerpts 

By default, you can either display full-posts or excerpts when displaying your posts. This may be fine for common blogging purposes, but specialized blogs may find it beneficial to exercise control over which type of post format is displayed. Here’s how to conditionally display either full-post or excerpt based on the presence of a custom field named “full-post-display”.

To implement this technique, setup the following loop in your theme file(s):

Then, for any post that you would like to display with full-post formatting, simply add a custom-field of “full-post-display” and give it a value of “true”.

Display Related Posts without a Plugin 

We don’t need no stinking plugins to display related posts! Here’s how to do the job using tags as the associative criteria.

Place the following code in your loop and take a nap or something:

Customize as needed. To change the number of posts, edit the line that says, “how many posts?”

Source: Enhanced version of the code provided by MichaelH (via WP Codex)

Drop-Dead Easy Styles for Author Comments 

This is almost too easy. To make your Author comments stand out from the crowd in WordPress 2.7 or better, use this code to apply some custom CSS stylez:

Display Upcoming Scheduled Posts 

Here’s an easy way to display a list of posts that are scheduled to be published at some point in the future. Create a page called “Upcoming Posts” (or whatever), and use this code for the loop:

In place, this code will output a list of all posts that exist within the database that have a post_status of future. I.e., anything that you have setup in draft mode that is set to auto-publish at a certain point in the future.

Display Automatic TinyURLs for Your Posts 

Make it super-easy for your visitors to share the URL of your posts with their favorite social-media service. Providing an alternate “short” version of your URLs is possible using the free TinyURL service and a couple snippets of code.

To display short URLs at the end of your posts, place this code into your theme’s functions.php file:

Then, call the function and display the URL by placing this code into your single.php file in the desired location within the loop:

That’s it! Your posts now feature super-short URLs for all of your tweet-hungry visitors. Tuper Tweet Tude!

Source: AH Business Technology

Implement a Site-Maintenance Page for Your Blog 

Ever do maintenance on your site? Certainly, we all do. Here’s an easy way to display a “site-maintenance” page that will display whatever content you desire. The key here is setting up your HTAccess file to handle the redirect properly.

TinyURL for this post: https://tinyurl.com/y3vlpp3o

Sorry, The Comment Form Is Temporarily Closed At This Time
:6of8
1
2
3
4
5
6
7
8
6
Next
You may also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

Language:English