1

Okay, so I am completely lost on how to display a custom post. I've looked everywhere and can't seem to wrap my mind around it.

So, I downloaded the plugin Custom Post Type UI to create a custom post. Here are the parameters of my custom post type:

  • Name: discount
  • Label: Discount
  • Supports: title, excerpt, thumbnail, author

    Then, I downloaded Advanced Custom Fields to give my custom post types some custom fields for users to edit.

    I didn't have any problems with that. My problem is that I have no idea how to implement this into my site. I would like it to act exactly like a blog post and also implement a masonry for it - just like my blog posts (I'm using the dante theme (I can't post any more links)).

    If anybody could help me out with this, or send me in the right direction, I would be so greatful. Thanks!

    2 Answers 2

    0

    Your custom post type's theme template would be called "single-[post type name].php".

    So for your example, you would want to create single-discount.php if your theme's root directory. Then you can start pulling your data from the posts through that.

    For Advanced Custom Fields, you'll want to get familiar with get_field() and the_field(). ACF has great documentation on their site for how to use the various field types (http://www.advancedcustomfields.com/resources/)

    3
    • Awesome, okay. So is this single-discount.php essentially creating a template in which to display the elements of my custom post?
      – Harry
      Jul 11, 2014 at 19:25
    • The single-discount.php file is the entire template for displaying a custom post. Your best bet is to take your theme's single.php (default post template), copy it, rename it, and remove/add things as-needed.
      – Joe
      Jul 11, 2014 at 19:30
    • Okay, so from what I understand, I need to first call up the fields I need used with the get_field command. And then I need to display those fields on the same .php file with the the_field command?
      – Harry
      Jul 11, 2014 at 19:35
    0

    To answer your questions in a general way, you could start by:

    • Theme Development. To understand how a WP theme works
    • Template Hierarchy. To understand what are the template files and how they are managed by WP
    • The Loop. To understand how WP shows the post
    • WP Query Class. To understand how to manage the posts, perhaps in the case of custom post type

    For the custom fields, @Joe has pointed you in the right direction. Hope it helps!

    0

    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.