Home Forums Backend Issues (wp-admin) Display custom post type content on custom page


Display custom post type content on custom page

  • Hello, I’m working to create a custom theme with custom post types, but have run into an issue with displaying custom post type content on a custom page template. I can’t seem to find a solution as I’m still familiarizing myself with wordpress.

    I have added custom post types (via the plugin custom post UI) and custom fields (via advanced custom fields). The custom post is correctly displaying in the new template page created (single-{post-type}.php).

    The problem however is that on the custom page.php template, the content isn’t displaying, and only the default field for the title of the page shows up. I have tried passing in the function, the_content(); in the loop but nothing displays. When I use the_title(); that works and displays the post titles. And if I echo the_field(‘field_name’) that displays the value too, but I’m not sure if it’s pointing directly to the post type.

    I did read the documentation on acf/load_value and was wondering if I need to input the code on that documentation in the function.php file. I’m also wondering if this is the correct approach?

    Has anyone also experienced this issue? Or am I overlooking a step to get the custom post to display on a custom page? Thank you!

  • The only place that content from the custom post type will display is in the file that you created single-{post-type}.php. You can show archives of the custom post type by creating archive-{post-type}.php. The template file page.php is not in the template hierarchy for a custom post type.

    This comes in handy for showing what templates will be looked for depending on what’s being loaded

  • Hi John,

    Thanks so much for responding. After reviewing the template hierarchy (thank you for sharing), I did create an archive-{post-type}.php template for the custom post. However, now I’m having an issue with the template not displaying any of the fields. I’ve created a custom loop with ACF fields, but I keep encountering a 500 server error. I’m still in the process of finding out what’s going on and will post my results if I find anything and/or a solution.

  • 500 internal server error? Sounds like you’re on an MS server. In your wp-config.php file add the following lines, this will turn on debugging so that you can hopefully see what the real error is.

    define( 'WP_DEBUG', true );
    define( 'WP_DEBUG_DISPLAY', true );
  • Ah, so what was happening was that the permalink wasn’t pointing to the correct file name. I didn’t delete the trash bin for the pages I had made for testing, so it was pointing to a different permalink. Just fixed it. So now what is displaying are the default links to the posts, but not the actual ACF fields I’m implementing in the code. Still in the process of finding out what’s going on.

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.