Enforcing a custom post type on the loop

In regular "query_posts" call includes default post type "post" only, but when you create a custom post type, you may need to call "query_post" for that custom post type only. Suppose you have a custom post type called "product"So, if you want to run query_posts...

Profile photo of WP Eden
WP Eden
December 9, 2012


READ MORE  

How to add custom header, footer or sidebar on different categories easily

To call a particular header, you will need to open your index.php and replace your normal header code with this one:if(is_category('Blogging')) { get_header('blogging'); } else { get_header(); }To get a separate sidebar for each all you need to do is add the following...

Profile photo of mrs.shoma
mrs.shoma
December 6, 2012


READ MORE  

Set an expiration date for your WordPress posts

This hack comes becomes very useful when you are running a contest because you might be posting information such as clues or hints that you don’t want to stay up for ever. Instead of manually removing the article, you can just make it expire automatically. It also works if you have a product that you...

Profile photo of mrs.shoma
mrs.shoma
December 6, 2012


READ MORE  

How to order categories by most recently updated

Add this code for displaying a category list based on which categories have been most recently updated.$cat_array = array();     $args=array(       'post_type' => 'post',       'post_status' => 'publish',       'posts_per_page'...

Profile photo of mrs.shoma
mrs.shoma
December 6, 2012


READ MORE  

How to reset options back to default with update_option

Adding this snippet to the functions.php of your wordpress theme will check if an option was updated by a user. If so, it will save it back to the default option you’ve set. Should work with almost any site option. (inspect element on input field and input’s “id” should be the “name” you...

Profile photo of mrs.shoma
mrs.shoma
December 6, 2012


READ MORE  

How to redirect back to referring page after login

Adding this snippet to the functions.php of your wordpress theme will redirect visitors to the page they were viewing after logging in.if ((isset($_GET) && $_GET != 'logout') || (isset($_POST) && !empty($_POST)) ) {        add_filter('login_redirect',...

Profile photo of mrs.shoma
mrs.shoma
December 6, 2012


READ MORE  

How to add bookmarks to admin bar using get_bookmarks

Adding this category bookmarks snippet to the functions.php of your wordpress theme will display a specified category of links / bookmarks to the wordpress admin bar. A great use for this snippet would be to provide resources bookmarks for your authors in a multiple author blog.function wps_adminbar_bookmarks()...

Profile photo of mrs.shoma
mrs.shoma
December 5, 2012


READ MORE  

How to remove title attribute from wp_list_categories

Adding this snippet to the functions.php of your wordpress theme will remove the title=”" attribute from the anchor tag when using wp_list_categories().function replace_wps_title_att($output) { $output = preg_replace('` title="(.+)"`', '', $output); ...

Profile photo of mrs.shoma
mrs.shoma
December 5, 2012


READ MORE  

How to Display Relative Dates in WordPress

Have you ever seen this in blog posts and comments and wondered how did this blogger manage to do this? Actually it is pretty easy. You would need to download a plugin called WP-Relative Date Once you have downloaded and activated the plugin, look in your single.php, index.php, and page.php for this...

Profile photo of mrs.shoma
mrs.shoma
December 5, 2012


READ MORE  

Customize Default Text and Title Attributes

While I’ve already touched on the customization of a few text elements of the default WordPress theme, there are other little text snippets that can be edited, removed, or appended to. There are also  title attributes that are embedded in anchor tags throughout the site. Here is one example, found...

Profile photo of mrs.shoma
mrs.shoma
December 5, 2012


READ MORE  

Change the Default Display of the Title Bar Content

The header.php file in WordPress’s default theme has a title bar that is coded like this:<title><?php wp_title('&laquo;', true, 'right'); ?><?php bloginfo('name'); ?></title> ...

Profile photo of mrs.shoma
mrs.shoma
December 5, 2012


READ MORE  

How to use a Custom Page as a Home Page in WordPress

This is one of the most wanted hacks that users want to know how to accomplish. First you need to learn how to create a custom page. You will need to duplicate your page.php or create a brand new .php file and add the following code at the very top :/* Template Name: WP Eden Home */You...

Profile photo of mrs.shoma
mrs.shoma
December 2, 2012


READ MORE