Category: Code Snippets
-

Prevent Browser Caching Image Files
[ad_1] When you are developing a site, you have to refresh page lot of times and you start to get a pretty good feel for what your browser is going to pick up on a single refresh, and what it won’t. For example, I find that if I overwrite an image file on the server,…
-

Check If a WordPress User is Logged In
[ad_1] Sometimes you want to show different content within WordPress based on whether a WordPress user is logged in or not. WordPress provides a simple way to perform this check with is_user_logged_in tag. It returns boolean true or false value and with the help of this tag, we can create unique messages for members, add…
-

Protect .svn Folders From Public Access
[ad_1] If you use WordPress with Subversion (svn) then you will probably notice .svn (metadata) folders on your server. These folders are used by the Subversion client to keep track of changes and determine what files need to be updated when getting the latest versions. They also contain information about what SVN server you are…
-

Set Minimum Word Count to Publish Post
[ad_1] If you’re running a WordPress blog with multiple authors, then it’s important for you to maintain your blog’s content quality. With WordPress, you can restrict your authors to publish a post without having enough content. Here is a code snippet that lets you set a minimum word count for your WordPress posts. You can…
-

Disable WordPress Admin Bar for All Users Except Admins
[ad_1] By default, each registered user has the option of showing the Admin Bar on the frontend and/or back-end of the website. And user can change these preferences, just by visiting Users > Your Profile and choose to show/hide admin bar. Although it’s nice to have for some users but sometimes you don’t want to…
-

Display All WP Query Variables in WordPress
[ad_1] When developing a WordPress theme or plugin, it may be very useful to be able to output all WP Query variables. Here is a simple code snippet to do it easily. Paste the code below on any files, where you’d like to display the WP Query variables. <?php // display all wp query variables…
-

Add Custom Image Size to Post Thumbnails
[ad_1] Here we will see we can we add additional custom image size to post thumbnails in WordPress media uploader to use in our WordPress theme. WordPress has a built-in feature for Post Thumbnails. When you upload an image in any post or in media library, WordPress automatically resize and crop image to some predefined…
-

Enqueue Scripts and Stylesheets in WordPress
[ad_1] If you are a designer or a developer then knowing the proper way to enqueue scripts and stylesheets in your WordPress themes and plugins is very important. Because if you don’t do it proper way then you will probably run the risk of conflicting with other themes and plugins, and potentially creating problems that…
-

Add Custom Post Types to Your RSS Feed
[ad_1] WordPress has in-built RSS feed allowing visitors to subscribe. This RSS feed normally consist of just blog posts and it does not include custom post types in default RSS feed. Although WordPress does not offer any setting to include custom post types in RSS feed, but we can modify the WordPress query to keep…
-

Get Current Page ID Outside The Loop
[ad_1] With WordPress sometimes you’re not always working inside the WordPress loop. When you are working inside the loop, template tag the_ID can be used to easily get current page ID but if you are working outside the loop then getting current page ID is little tricky. Let’s look at how this is done. Inside…