D
D
dicem2016-03-04 15:56:45
WordPress
dicem, 2016-03-04 15:56:45

Advanced Custom Fields how to display the value of an additional field in a category?

Installed the Advanced Custom Fields plugin on WP.
Created a new field for creating/editing categories.
fbf65364ecb94725a6f004d1fe237a9b.pngfd172d4e91a648ff88b30f8f23a82c43.png
Anyway, what a task. I need to create a field when creating/editing a category. A field with another heading H1. If this field is empty, then the standard title is used, and if the new field is filled with data, then the category title = data of the new field.
I can't display the field values ​​in any way, I use the following function:

<?php 
     the_field('h1_caption', $term); 
?>

I really ask for help.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
mr_dev1l, 2016-03-04
@dicem

headings are used get_field
and here is the whole code:

<?php $cat_page_title = get_field('h1_caption', "category_".get_query_var('cat'));
      if (!empty($cat_page_title)) {
           echo $cat_page_title;
            } else 
          {                                                                    
          single_cat_title();
            }
                ?>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question