Support

Account

Home Forums General Issues Simple code

Solved

Simple code

  • Hi all, i am total noob in programing, so if someone can help with small code.

    I have large number of posts, each post have custom fields (team_1 and team_2) which i stated in advanced custom filed plugin.

    And i want that engine lists all that fields, so i am using some code i found online

    <?php
    while ( have_posts() ) : the_post();
    the_field(‘team_1’);
    ?>
    </br>
    <?php
    the_field(‘team_2’);
    ?>
    </br>
    <?php
    endwhile;
    ?>

    So that i get result like
    Team 1 name
    Team 2 name
    then again from second post
    Team 1 name
    Team 2 name
    etc.

    But nothing happens.
    Please, if someone can help with this small issue

  • Hi @ivanko

    Could you please check if the values are saved in the backend? Also, could you please manually pass the post ID as the second parameter of the the_field() function like the following?

    the_field(‘team_2’, 99);

    Where 99 is the ID of your post. This will check if the value is saved correctly and can be returned correctly too.

    Could you also take a look at this page: http://www.advancedcustomfields.com/resources/displaying-custom-field-values-in-your-theme/?

    Thanks!

  • Hi, and thank you for reply!
    Yes, when i put post ID, i get result, it works.
    But without ID it does not work.
    But i am using Exec-PHP plugin for inserting php in wordpress and i think it’s the problem with that plugin since the code works in normal php file.
    Thank you very much!
    Best regards,
    Ivanko

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

The topic ‘Simple code’ is closed to new replies.