Support

Account

Home Forums Front-end Issues fields in category -> post still not showing up

Unread

fields in category -> post still not showing up

  • Original problem:

    Theme: Mobile Friendly
    WP version: 4.9.1
    Problem: I have a created a field group (ACF) that has (2) fields; a) text (Mattaymom) and b) number (class_number) , and edited the single.php file, see below. When I view the single post this information (2) and other information (wp-textbox) displays OK. However, when the post is viewed by the user clicking on a category that links to the same post, this information does not display (2), and only the text from the wp-textbox. I would like to use more fields in the future once I can resolve this issue.

    <div id=”primary” class=”content-area”>
    <main id=”main” class=”site-main” role=”main”>
    <?php while ( have_posts() ) : the_post(); ?>
    <H4>Matthayom/Class/Feedback<H4>
    <H5>Matthayom <?php the_field( ‘matthayom’ ); ?><br/><H5>
    <H5>Class <?php the_field( ‘class_number’ ); ?><br/><H5>
    <H5><?php the_field( ‘comment’ ); ?><br/><H%>

    <?php get_template_part( ‘content’, ‘single’ ); ?>

    Original reply:

    Hi Simon,

    Thanks for the email.

    All the template functions (get_field, the_field, etc) can be used to load values from another post, however, a second parameter is required to target the post.
    Each post has a unique ID which can be found in the URL when editing or found via code such as $post->id.

    I believe when you are clicking the categories link it directs you to the category page instead of the post itself.

    Kindly try:

    <div id=”primary” class=”content-area”>
    <main id=”main” class=”site-main” role=”main”>
    <?php while ( have_posts() ) : the_post(); ?>
    <H4>Matthayom/Class/Feedback<H4>
    <H5>Matthayom <?php the_field( ‘matthayom’, $post->ID ); ?><br/><H5>
    <H5>Class <?php the_field( ‘class_number’ , $post->ID); ?><br/><H5>
    <H5><?php the_field( ‘comment’, $post->ID ); ?><br/><H%>

    <?php get_template_part( ‘content’, ‘single’ ); ?>

    Let me know how it works for you.

    second reply: still not working?
    Thank you for your prompt reply. I inserted the code you sent to replace my code into the single.php file, however the issue still remains. What you said in your explanation made a lot of sense, however I still cannot trouble shoot the problem, from looking on the internet and on your support site.

    Thank you in advance.

Viewing 1 post (of 1 total)

The topic ‘fields in category -> post still not showing up’ is closed to new replies.