Kannan
Kannan

Reputation: 347

How to get post custom field value?

Fatal error: Call to undefined function get_field() in /opt/lampp/htdocs/element/wp-content/themes/element/post_types/post-talent.php on line 13

<?php
$category = get_the_category();
$query = substr_replace($category[0]->name, " ", strlen($category[0]->name)-1); ?>


<div id="content" class="talent" role="main">

    <h1><?php the_title(); ?></h1>
    <div class="post-body">
        <div class="entry">

            <?php
            if ( get_field('talent_work') ) :
                static $count_em;
                while ( has_sub_field( 'talent_work' ) ) : ++$count_em; ?>

                    <div class="talent-work talent-work-<?php echo $count_em; ?>">
                        <?php if ( $img = get_sub_field('preview_image') ) : ?>
                            <img src="<?php echo $img['sizes']['large']; ?>">
                        <?php endif; ?>
                        <h3><?php echo get_sub_field('video_client'); ?></h3>
                        <p><?php echo get_sub_field('video_title'); ?></p>

                        <div class="embed hidden">
                            <?php echo get_sub_field('embed_code'); ?>
                        </div>

                    </div><!-- / .talent-work -->
                <?php endwhile;
            endif; ?>

        </div><!-- / .entry -->
    </div><!-- / .post-body -->

    <div class="modal" id="talent-modal">
        <div class="modal-header">
            <h3></h3>
            <div class="close">
                <a href="#" class="close-button">Close</a>
            </div>
        </div>
        <div class="iframe-wrap"></div>
    </div><!-- / .talent-modal -->

</div><!-- #content -->

Upvotes: 1

Views: 86

Answers (1)

Mike
Mike

Reputation: 8877

There are several causes for this:

  1. The plugin isn't activated or installed. I'm going to guess this isn't the case, but it's always worth sanity checking, just in case you've done something by accident, such as renaming a directory.
  2. Often, when updating ACF, you need to rename the plugin directory, rename it back, and then reactivate the plugin. I'm not really sure why, but there are lots of other threads which say this fixes the issue.
  3. There have been issues with ACF when WordPress has been updated, please make sure both are up to date.

Upvotes: 1

Related Questions