Wordpress tutorials and examples

WordPress – how to exclude specific tag posts from a tag archive page

WordPress will display all posts on a tag archive page which are tagged with that tag. Sometimes we want to exclude posts of more specific read more

How to override priority and change frequency in Yoast xml sitemap

It is important to maintain healthy xml sitemap for your site. In case you are using Yoast SEO plugin to generate xml sitemap for a read more

WordPress – customize posts per page for tag, category and date archive pages

The following code can be used to have separate value of posts per page for various archive pages (category, tag, date, author, etc.)

WordPress – customize category and tag links

In case you need to create a custom link for category or tag, the you can term_link filter. This can be useful in case you read more

WordPress – get posts/pages with missing meta key

Get post_type page with missing meta_key Get post_type post with missing meta_key

How to view wordpress current version

If you want view the version of currently installed wordpress for a site, here are few approaches. View version using dashboard glance section If you read more

WordPress – how to create custom tag cloud

WordPress has support for displaying tag cloud using wp_tag_cloud. It displays tag cloud and has support for including and excluding tags and specifying mininum and read more

WordPress how to check if a post is being viewed by admin

In WordPress you may want to do certain things only when admin user is viewing a post. Here is quick code snippet to know if read more

How to show wordpress pages on front page with skip_home custom field

By default WordPress pages donot show up on home page. Only posts are displayed on home page. Here is wordpress php code which can be read more

Fetch wordpress rss feed as FeedBurner user agent on command line

In case you have setup your wordpress feed to redirect to Feedburner url for regular user-agents, you can use either curl or wget (Mac or read more

WordPress – how to add filter to description meta tag

If you using Yoast seo plugin, then you can use its filter wpseo_metadesc to change meta description tag as per your needs. Typically you want read more

WordPress – write custom php log to separate file

Why write php log to separate file Using default php error log in wordpress php code for informational messages can pollute php error log file. read more

Convert wordpress page to posts and vice versa

Sometimes we want to convert a wordpress page to post or vice versa. WordPress treats a post slightly differently. e.g. WordPress shows posts automatically in read more

How to customize wordpress rss feed

By defaul WordPress will include all posts sorted by creation time for rss feed. If you want to customize wordpress feed, you can write custom read more

How to ping feedburner to force update rss cache

If you are using Feedburner for RSS feed management, it will usually update your feed at a regular interval. In case you are debugging or read more

Find all user created wordpress custom field keys

Sometime we need to find all user created custom field key names (or meta key) in wordpress. This may be needed to find all posts read more

WordPress – exclude specific posts from archive pages

Sometime we need to exclude specic posts and pages from wordpress archive pages. If there are some internal pages behind auth, you may want to read more

find if a wordpress page is leaf page

Sometime we want to consider pages which have children as browse pages and may treat them separately in plugins etc. For example we may not read more

How to display wordpress top level pages

Displaying wordpress top level pages may be useful for displaying sitemap or browse interface on a wordpress site. Here is the code you can use read more

Setup xdebug for remote wordpress debugging

Using xdebug is pretty useful for debugging and sometimes understanding existing code. In a typical setup where wordpress in installed remotely on EC2 or any read more

How to remove xmlrpc from wordpress headers

If you don’t need xmlrpc in your wordpress, you can disable it at various places like http x-pingback header, html meta tags, etc. Here are read more

How to upgrade wordpress manually

Recently I upgraded wordpress from version 3.5.1 to 4.3.1. There are couple of ways you can upgrade wordpress and easiest one is do it using read more

How to include wordpress pages in archives

WordPress archives are very useful in providing users and search engine bots like Googlebot a great way to browse all content on a wordpress site. read more

migrate multiple mysql databases using mysqldump on Linux

Sometimes we need to migrate all mysql databases to a new machine. This can be the case when you are migrating your multiple wordpress blogs read more

prevent wordpress xmlrpc.php attack

Sometimes you may see too many POST requests to xmlrpc.php in your apache access log. Large number of hits to xmlrpc.php can slow down your read more

How to include angularjs javascript in wordpress post

AngularJS is great framework for declaring dynamic views in HTML documents. To include AngularJS we just need to include the angularjs javascript file in the read more

How to include bootstrap javascript and css in wordpress post

Bootstrap is pretty handy javascript and css library/layer over jquery which provides many useful pre-built functionalities like responsive design, transitions, modals, buttons, etc. In case read more

Meta robot noindex, follow for wordpress tags and category pages

In case you want search engines to either not index or not follow links on a page, you can use robot meta tag. The default read more

Internal vs external css

There are two ways to include a css on a site. In case you are using a wordpress site, many plugins involving frontend ui element read more

How to capture php code or included file output in a variable

Sometimes we want to reuse a php function or include a file and want to capture  the output (from echo, print, etc.) of that function/file read more

WordPress SEO – beginner guide

Most of the SEO (Search engine optimization) can be done with very little effort. Ideally speaking there should not be too much effort in SEO read more

How to setup wordpress custom query params with pretty url format

WordPress pages can handle query parameters in url in the traditional format of “key=value”. e.g. If you want to create a page to display details read more

How to display date in wordpress pages

The default Twenty Twelve theme which comes with wordpress and many other themes display creation date in wordpress posts but do not display any date read more

Embed youtube video with javascript on-click lazy loading approach

Embedding youtube video using the default iframe code fetches couple of files and makes the page load little slower for the end user. Many users read more

How to Preload cache in wordpress on Linux

I’m using memcache with w3c total cache plugin to cache pages on my wordpress site on Ubuntu Linux. The way it works is whenever someone read more

How to display wordpress page list with specific custom field value

WordPress lets you display a list of pages as links with many customizations. You can use wp_list_pages or get_pages to display or get list of pages. read more

How to setup MailChimp Rss email campaign

MailChimp can be used to setup email campaign and send a regular email newsletter to all the email address in a list. Most common use read more

Google feedburner email subscription vs Mailchimp

Google feedburner offers an email subscription to your feeds. So far I was using that. Mailchimp is one of the most popular email list management read more

How to setup Google feedburner email subscription newsletter

If you are using Google feedburner for rss feeds, you can setup feedburner email subscription newsletter within few minutes. I have been using it for quite read more

How to redirect wordpress feed to feedburner feed url

If you have been using wordpress for directly serving rss feed and have recently migrated to feedburner, then some of your users are still being read more

How to use your own domain name for feedburner feed urls

When you create a feed your your wordpress blog you get a url of the form http://feeds.feedburner.com/feedid. You can change feeds.feedburner.com to your own domain. It read more

How to create rss feed for wordpress blog on Google feedburner

When you install wordpress you automatically get feed or rss setup at url /feed/ (or /rss/). It seems to be a good option to continue read more

How to migrate your site from one domain to another

Migrating a site from one domain to another can be a daunting task. But if we create a clear plan then it is a manageable task. read more

How to use wordpress facebook plugin comments box with lazy loading

WordPress facebook plugin lets you embed facebook comment box in your posts and pages along with many other features. One biggest benefit of facebook comment box read more

How to use Google custom search with lazy loading approach

If you have Google adsense account then you can use Google custom site search for your website. I’m using it on a wordpress site but read more

How to use w3 total cache for wordpress

W3 total cache by Frederick Townes is probably the best wordpress cache plugin. Setting it up for best outcome can take sometime. But once you get read more

How to and why disable wordpress cron

WordPress crons are different from traditional Linux or Windows crons. Traditional cron runs as independent processes at regular interval. WordPress crons are php hooks which read more

How to use rsync for production release automation

Rsync can be used to automate the production releases for wordpress or any other site. I maintain two wordpress sites – one for development purpose and one read more

How to use google custom search for wordpress site

WordPress comes with a default search which searches posts and pages from your site. It works pretty decent. Here is why you should consider switching read more

Should I block Googlebot from crawling javascript and css?

I noticed that google bot is crawling javascript and css regularly from by wordpress blog site. Here are some entries from my apache log: 66.249.75.66 read more

No frills social share links for WordPress sites

There are many plugins available for WordPress which lets visitors share the post or current page on various social networking sites like Google Plus, Facebook, read more

WordPress multisite network vs normal installation

When it is required to have more than one wordpress installations it can get little tricky. There are multiple way to do that. Do multiple read more

How to automate wordpress sandbox setup on Linux

Maintaining a wordpress site can be pretty involving task specially when you have so many plugins with regular updates. Many time you have to experiment new plugins, read more

Tips on improving the performance of your WordPress blog or site

WordPress is a great blogging platform and there are plugins for pretty much everything you need. But with too many plugins it affects the performance read more

How to install wordpress on Amazon AWS-EC2 Classic Ubuntu Linux micro instance

[Update: This post is applicable for Amazon classic infrastructure. Now you should use Amazon VPC infrastructure and steps may be slightly different. We’ll soon write read more

How to set up google analytics profiles for domain and sub-domain tracking

Google analytics can be used to track a domain and its one or more subdomains. This is pretty useful if you are having one or read more

www vs non-www domain which is better for your site?

I have been doing some research on whether to use www or not in domain of the urls of the site. If you setup wordpress read more

Using python to analyze bots from apache logs

Apache logs contains pretty useful information about various visitors and bots coming to your site. Here is how a typical apache log entry looks like: read more

How to prevent your test blog from google crawling but show adsense ads

I guess most of us maintain a test or sandbox blog to try out new plugins and do experiments which we can’t afford on main read more

How to check the performance of a plugin using mysql query log

Installing too many plugins can hurt wordpress blog performance as plugins may lead to more queries. One quick way to check the impact of a read more

How to migrate wordpress from root to sub directory

Migrating wordpress from root to subdirectory is not a difficult task but should be done carefully. Here are the steps which can be followed. Terminology read more