Support

Account

Home Forums ACF PRO Custom post type question?

Solving

Custom post type question?

  • Hi folks,

    Starting to venture into the world of Web Development and I need help, so parden the stupid question, lol.

    I’m creating a portfolio site using underscores. So no theme builder. Trying to go at it learning the hard way, and while I’m learning as I go, some things just go over my big fat head.

    I created a custom post type with CPTUI named “Portfolio”. I can not for the life of me figure out how to display custom fields for that particular post type. Everything works on the home page with the “<?php get_field (”);?>, but I can’t get it to hook on the custom post page called “/portfolio”.

    I can see the fields on the portfolio page, but it’s just now showing up on the page itself.

    What am I doing wrong?? Thanks in advance!!

    L

  • What template file are you editing to show the values?

    How are you calling get_field()?

    are your field calls inside of “The Loop”?

  • Hi John,

    Thank you for responding. I’ll try to answer your questions. Please bare with me as I’m still learning…

    What template file are you editing to show the values?
    I created a single-portfolio.php file to use as my template for sections.

    How are you calling get_field()?
    Pretty sure this is wrong, but I was following these instructions..
    https://www.advancedcustomfields.com/resources/adding-fields-posts/

    So in my case it looked like this:

    <?php
    the_post();

    // vars
    $project_title = get_field(‘project_title’);
    ?>

    <h6><?php the_field(‘project_title’); ?></h6>

    are your field calls inside of “The Loop”?
    Sadly no. Not sure how this loop is supposed to look like…

    Again, thanks again in advance…

  • All post templates, even single post templates, should contain the WP main loop.

    
    while (have_posts()) {
      the_post();
      // all post specific code goes here
    }
    

    You should see an example of this if you look at any of the single post templates included in your starter theme.

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

You must be logged in to reply to this topic.