wordpress sort custom post type columns

When you’re creating custom post types into your wordpress site you can see it’s posts as list.But there is no option to sort each columns.You have to manually add this facility to do this.I’ll describe here very simply how to do this without any plugin.
Continue reading wordpress sort custom post type columns

WordPress restrict access to custom post types for user roles

If you’re creating custom post types to wordpress site sometimes you need to restrict access to custom post types from back-end to other users. For a example if you created the custom post type named “Campaigns” and you want to enable that “Campaigns” page from admin panel only administrator user role.To do this I’ll show very simple method by explaining from start to end.Hope every users can understand easily. Continue reading WordPress restrict access to custom post types for user roles

WordPress create custom post types with tags and categories

If you’re working with wordpress sometimes you want to add custom post types with it’s tags and categories to add into admin panel.For a example, “News” custom post type.You can follow this tutorial guide to add unique custom post types with it’s tags and categories to admin panel.No errors,no tags and categories mixing with other post types.No usages of plugins.

Features

  • Unlimited Custom post types
  • No mixing with other post types
  • Creating unique tags and categories
  • No usages of plugins
  • Simple and efficient code
  • Customize display columns
  • Custom admin menu icon
  • Sort column by post name
  • Filter posts by categories

Now we’ll see how to add custom post type to wp admin panel.
-First you must go to the theme folder and open the functions.php file.If you’re using premium themes you can use custom-functions.php or theme-function.php.
-After that at the end of the file put the following piece of code.Here I’m using “News” custom post type.

 

Step-1

After add the above code you can see the changes as following.

custom post types

Further note:
If you want to add custom menu icon go to following link and select the icon.Then copy it’s name(Ex:-dashicons-format-aside) and put here.
Dashicons

Step-2

Main part is finished.Now we’ll add it’s categories.Note here,I’ll explain little bit mistake many user’s doing.
If you add following mentioned code, you can see categories mixing with other post type’s,default post’s categories.So DON’T USE Following code. ‘taxonomies’ => array(‘category’) ,// mixing with others.

This is the correct code.

 

Step-3

Now we have to do the customize columns as the following diagram.
custom post types columns

Add the following code to functions.php file.

 

Step-4

Filter news and sort by name.
To do that add this code.

 

Step-5

Adding Tags to Custom post type. You can add following code to add tags to News post types.No mixing with other post types.

Now you have implemented all codes and after that you can see custom post types with tags and categories,sorting,filtering functions.
custom post types all

Error fixing

May be when you visited to the category page you may not be seen the post related to that category. To fix this add the following code to function.php file.

Additional Notes

If you want to add more admin menu icons then add this code to functions.php file.

Follow my another post describing this.

Download full source code

WordPress find specific shortcodes from post & page contents

How do you find specific shortcode from the wordpress page or post contents? For a example if you are using “gallery” shortcode, you want to check that code if exist or not for some modifications.I wanted this for gallery shortcode if exist for some gallery width changes.So I found some codes and I have improved php codes and implementing here to you.
Continue reading WordPress find specific shortcodes from post & page contents

WordPress get woocommerce featured products

In the wordpress woocommerce web site’s contains various featured products and sometimes we want to get the featured products without any plugins.For a example we want to get featured products to create featured slider.So I’m going to tell you have to get woocommerce featured products without any plugins and grammatically.

Continue reading WordPress get woocommerce featured products

WordPress create custom post types/taxonomies

Custom Post Types are a new set of administrative options appearing along with the default post types such as Posts, Pages, Attachments etc. A Custom Post Type can store any type of information. It has a editor, media uploader and uses the existing WordPress table structure for ease in data management.

By default, WordPress comes with 3 taxonomies:post tag, categories and link categories. Essentially, a taxonomy is a way of classifying data. Continue reading WordPress create custom post types/taxonomies

WordPress create custom meta boxes

This post is explaining creating wordpress custom meta boxes/meta data in easy,secure & proper way.A post meta box is a draggable box shown on the post adding/editing page. Its purpose is to allow the user to enter information in addition to the main post content.

There are two types of meta boxes. Continue reading WordPress create custom meta boxes

WordPress get recent post except first 3 posts

How to check and get recent post 3 in wordpress? On another way it’s calling exclude posts.I’m going to explain this in 2 methods.First method is getting first 3 posts into an array. When we’re going to display the posts, checking current post ID if exist in that array. If exist continue the loop.If not exist then display the posts.Other method is passing parameter “offset”.
Continue reading WordPress get recent post except first 3 posts