I have a post type shopping and in my single.php I am trying to get a certain template for this post type. So I did:

\\ in the single.php
get_template_part( 'template-parts/content', get_post_format() );

and in template-parts directory, I created a file named content-shopping.php. But no matter what, the single template used is the default content.php.

However, if I do something like this:

if ( 'shopping' === get_post_type() ) {
  get_template_part( 'template-parts/content-shopping' );
  get_template_part( 'template-parts/content', get_post_format() );

then the template is used for that post type. I am not sure why the first method is not working. Any idea?

1 Answer 1


get_post_format and get_post_type are completely different.

Post Formats can be one of the following:

  • 'standard' (default one)
  • 'aside'
  • 'chat'
  • 'gallery'
  • 'link'
  • 'image'
  • 'quote'
  • 'status'
  • 'video'
  • 'audio'

And shopping is the post type you have created and not post format. You can add post format for the post type(shopping) like this

add_post_type_support( 'shopping', 'post-formats' );
  • 1
    ah, stupid me. I thought by creating the post type, I added a special post format beside those. In the first example, I just replaced post format with get_post_type and it works.
    – Rain Man
    Commented Jun 20, 2016 at 20:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.