Support

Account

Home Forums Backend Issues (wp-admin) Make custom fields visible

Solving

Make custom fields visible

  • This is probably simple but I still can’t figure it out.

    I’m trying to make some custom fields appear in my newspaper 6 theme.

    I know I’m editing the right .php file as I can make simple html appear there but no matter what code I enter I’m not able to get the custom fields appear.

    I tried the export code function but nothing happened. So I’ve also tried making custom fields visible by adding code like:

    <?php echo get_field(‘company_name’);?>

    <?php the_field(‘company_name’); ?>

    <?php get_field(‘company_name’); ?>

    As I’m a complete beginner I hope somebody can give me some pointers.

    Kind regards
    Lars

  • Some questions.

    Is the content added for this field for a post, on an options page, or something else?

    What template are you adding the code the_field('company_name') to?

    Is this inside “The Loop”? since you say you’re a beginner I will explain “The Loop”. the loop usually starts with something that looks like while(have_posts) : and ends with end while;

  • Hi John,

    and thanks so much for trying to help out.

    The content for this field is for a post.

    The template is Newspaper 6 by ThemeForrest. And I do believe it is inside a Loop – the name of the php. file is “loop single”. The starts of with an “if-statement” which also can be loop if my extremely basic php knowledge is correct?

    I have attached a print screen of the code – as well as a printscreen of the setup in acf as well as inside the wp-post. So If I’m doing it correctly “VS Moda” should appear in the post – but nothing can be seen.

    Kind regards
    Lars

  • I don’t have access to that theme, and can’t say with 100% certainty, but I think where you’re trying to get the field is outside the loop.

    My guess is that the post loop is actually in whatever file or code is loaded by this line.

    
    <?php echo $td_mod_single->get_content(); ?>
    

    Either that or there isn’t a real loop for this theme. Some theme authors do things in incorrect ways. It is possible to get the current post id without having a loop, but without having a loop you must always supply the post id because without it WP and ACF won’t figure it out for you.

    Anyway, you can try this.

    
    <?php 
      $queried_object = get_queried_object();
      the_field('company_name', $queried_object->ID);
    ?>
    
Viewing 4 posts - 1 through 4 (of 4 total)

The topic ‘Make custom fields visible’ is closed to new replies.