Display Posts

Show Content Only on Home Page or Front Page

The following code will allow you to display content on the home page, or front page, only.

If you want to use this as a conditional statement you could do the following:

Get the Posts of a Specific Category

The following snippet will get the posts of a specific category. So if you wanted to have a page that just shows posts of a certain category this would do it .

In this example we are going to get posts from the category with an ID of “5” […]

Get Category of Current Custom Post Type

The following will list the categories of the current post type.

If you want to exclude one of the categories so it does not show add this:

Featured Image URL

The following snippet will give you just the url for the featured image without wrapping it in any tags.

Code credit to: http://www.wpbeginner.com/wp-themes/how-to-get-the-post-thumbnail-url-in-wordpress/

Only Show if User is Logged in

The following snippet can be used to show content only to users who are currently logged in.

Or with an else statement:

taxonomy-product-categories.php template

Character limit

The following function will create a custom function to create a unique character limit excerpt for the post. Add the following to functions.php:

Add the following to the page template to get the function to show: