Tag Archives: post

Snippet: Get Random Post Link

Code snippets to fetch link of a random post of your blog.

sorting

Snippet: Numeric sortable column for custom post type in admin panel

Many developer used Property, Car, Product and several others as a custom post type which, by default, sorted by publishing date (very odd). This fairly simple snippet details how one can add a sortable numeric column (for example a pricing column) in listing view of custom post type. It is quite useful as custom post types are getting popular day by day.

content-tree

Snippet: True in_category Conditional function

This is an advanced version of default in_category function. This function not only check for existance of post in the specified categories but also in all the subcategories down in the tree. It has same in_category parameters So you can use it in replacement of in_category.

alternative-post-coloring

Snippet: Add “alt” CSS Class to Alternative Posts

If you want to have different look and feel for post one after the another. This snippet will let do that quite easily. It will add “alt” class to alternative posts and you can then change, lets say, background color or border to make it different from the adjacent posts.

require-featured-image

Snippet: Require Post Thumbnail to be Uploaded Before Publishing

This short snippet requires authors and admins to set a post thumbnail before publishing any article. It will update the post and all of its contents but wont publish it until the thumbnail is set. For custom post types, you just need to change the “get_post_type” condition to your custom post type.

media-metabox-fi

Snippet: Media Metabox to add additional images to posts

This snippet adds a gallery metabox where admin can either upload images through WordPress Uploader or put in the image URL directly. This metabox is very useful for the custom post types for which you want to upload multiple images. Some good examples are, real estate properties, work portfolios and store products. All of these would have a featured image and some images to be displayed in a (for example) slider to explain it features and qualities.

Admin Widget of to Display Future Posts

Widget: Display Future or Upcoming Posts

This widget allows you to display scheduled posts or custom post type. You can limit number of posts to display and toggle to display thumbnail, link to the post and change the order of the posts.