Home Forums General Issues Cannot get the data


Cannot get the data

  • I added a text field for a custom category link, but it is not working. This is the last piece of this website and it has been driving me nuts. I checked your docs and I think I am doing it right, so not sure what is wrong 🙁

    The relevant code is below, but the specific call I have is <?php get_field( 'category_link' ); ?>

    <div id="scholarships">
        <h1 class="grid-heading">Not sure where to begin?</h1>
        <h2 class="grid-sub-heading">Try browsing these popular scholarship categories</h2>
            $categories = get_categories('hide_empty=0&exclude=13,1,1460&orderby=title&order=ASC');
            if (!empty($categories)) {
                $i = 0;
                foreach ($categories as $cat) {
                    $class = ( $i % 3 ) ? 'span4' : 'span4';
                    $thumbnail_id = get_option('seamless_term_thumb_' . $cat->term_id);
                    $image        = wp_get_attachment_url($thumbnail_id);
                    <div class="<?php echo $class . ' ' . 'category-' . $cat->term_id;?>">
                        <div class="thumb">
                            <a href="<?php get_field( 'category_link' ); ?>">
                                <img src="<?php echo $image; ?>" alt="<?php echo get_cat_name($cat->term_id); ?>" class="item-image">
                        </div>  <!-- end .thumb -->
        <?php $i++; } } ?>
        <div id="moreLessSwitch">Show More Scholarships</div>
  • Hi @Jagst3r21

    If the field ‘category_link’ is saved to a taxonomy term, then you must specify the $post_id parameter as explained on this tutorial:

    Hope that helps


  • I tried this, but no luck 🙁

    <?php echo get_field('category_link', $post->ID); ?>

  • I have the same problem. When I do a var_dump, I get nothing:

    var_dump(get_field("test")); returns bool(false)

  • I have the same issue with the var_dump…this is a rather urgent issue so I hope it is an easy fix…

  • Hi @Jagst3r21

    Please read over the linked documentation. When loading a vlaue from a term, you must use the correct $post_id parameter.

    This is not $post->ID.

    The tutorial will cover how to find the correct $post_id


  • Sir, I do not follow. From the doc it seems you have to specify the category. I cannot work like that because I need it to be automatically added because it is in a loop I have…

  • Hi @Jagst3r21

    When you say it needs to by dynamic, what do you mean? What is the logic / rules that the code needs to follow?

    I can see that in your code you have a loop which loops over each $cat. You can construct the $post_id parameter from the data available in $cat.

    Hope that helps.


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

The topic ‘Cannot get the data’ is closed to new replies.