# ACF field not working when set to nav link

**URL:** https://forum.pinegrow.com/t/acf-field-not-working-when-set-to-nav-link/7733
**Category:** Questions
**Created:** [February 10, 2023, 4:21pm UTC](https://forum.pinegrow.com/t/acf-field-not-working-when-set-to-nav-link/7733 "2023-02-10T16:21:08Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Hannah](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/hannah/32/5047_2.png) [@Hannah](https://forum.pinegrow.com/u/Hannah)
#### Post date: [February 10, 2023, 4:21pm UTC](https://forum.pinegrow.com/t/acf-field-not-working-when-set-to-nav-link/7733/1 "2023-02-10T16:21:08Z")

</div>

Hi team, I would like to have the navigation links in my header editable using ACF. But when I place the acf field in the ‘a’ tag Pinegrow Dom tree and select href, the link does not take you to the page url, provided in the acf field. What am I missing? I have included a screen recording to explain the problem further.

> **[Screen Recording 2023-02-10 at 15.59.31.mov](https://drive.google.com/file/d/1jk12rl4zYwPkAVOzqdff2iVzO6qKNaFo/view?usp=share_link)**
>
> Google Drive file.

---

<div class="post-metadata">

### Author: ![jonroc](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/jonroc/32/2805_2.png) [@jonroc](https://forum.pinegrow.com/u/jonroc)
#### Post date: [February 10, 2023, 7:37pm UTC](https://forum.pinegrow.com/t/acf-field-not-working-when-set-to-nav-link/7733/2 "2023-02-10T19:37:11Z")

</div>

Your felid name is wrong in PG 😊 try `main_sub-menu_link`, in your video you had `main_submenu_link`

I can’t even calculate how much it has cost me over the years from misplaced commas, semicolons, or misspelled variable, so you’re not alone in this 🤣 🤪

---

<div class="post-metadata">

### Author: ![Hannah](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/hannah/32/5047_2.png) [@Hannah](https://forum.pinegrow.com/u/Hannah)
#### Post date: [February 11, 2023, 9:11am UTC](https://forum.pinegrow.com/t/acf-field-not-working-when-set-to-nav-link/7733/3 "2023-02-11T09:11:22Z")

</div>

I think with coding you just need another pair of eyes, especially when you’ve been staring at the problems for hours! 😆  
Unfortunately that fix wasn’t enough. I noticed that that all the set links worked if you were selecting them from the home page but if you were selecting them from a different page, it didn’t work. I thought this was because I set the acf fields from my home page so I created a global options page instead. But the issue still persists. Any ideas why?

---

<div class="post-metadata">

### Author: ![Hannah](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/hannah/32/5047_2.png) [@Hannah](https://forum.pinegrow.com/u/Hannah)
#### Post date: [February 11, 2023, 2:00pm UTC](https://forum.pinegrow.com/t/acf-field-not-working-when-set-to-nav-link/7733/4 "2023-02-11T14:00:28Z")

</div>

I found the issue.  
It’s to do with the code that Pinegrow generates.  
When adding an ACF link for a field titled ‘main\_sub-menu\_link\_2’, Pinegrow generates the following code:

```auto
<?php echo esc_url( get_field( 'main_sub-menu_link_2' ) ); ?>

```

This is acceptable if you are not needing the link to be available globally. but if you are using ACF options, the following seems to have worked for me:

```auto
<?php if( get_field('main_sub-menu_link','options') ){ ?>
<?php the_field('main_sub-menu_link','options'); ?>
<?php } ?>

```

I believe the significant part of the code is the ‘options’ parameter, which directs the code to be active globally. Now I have had to include this into the header.php file, which Pinegrow generates. I think we are not meant touch files that are generated by Pinegrow. How can I make the changes necessary without touching the generated files @matjaz? Thanks in advance.

---

<div class="post-metadata">

### Author: ![matjaz](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/matjaz/32/5_2.png) [@matjaz](https://forum.pinegrow.com/u/matjaz)
#### Post date: [February 12, 2023, 5:22am UTC](https://forum.pinegrow.com/t/acf-field-not-working-when-set-to-nav-link/7733/5 "2023-02-12T05:22:49Z")

</div>

@Hannah using Function action with If condition action is the way to go in this case:

```auto
<p class="mb-0" cms-function="code" cms-function-type="element" cms-function-code="the_field('main_sub-menu_link','options')" wp-if-custom="get_field('main_sub-menu_link','options')">Lorem ipsum dolor sit amet, consectetur adipiscing elit eiusmod</p>

```

Result:

 ![customcode](https://canada1.discourse-cdn.com/flex036/uploads/pinegrow/original/2X/c/c644599e8f2c1ada5cd56afd0e3079c35ad37cc6.jpeg)

Post Field action only works with post fields, not global ones.

---

<div class="post-metadata">

### Author: ![Hannah](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.pinegrow.com/hannah/32/5047_2.png) [@Hannah](https://forum.pinegrow.com/u/Hannah)
#### Post date: [February 12, 2023, 8:52am UTC](https://forum.pinegrow.com/t/acf-field-not-working-when-set-to-nav-link/7733/6 "2023-02-12T08:52:29Z")

</div>

This has worked beautifully. Thank you.
