Home › Forums › General Issues › Location rules not working
So I am using the latest version 4.2.2, with WordPress 3.6.
For some reason the custom fields I create all show in every post, well, not all really since some of them are stuck on load. This happens even though I set the location rules to specific posts in my site.
Any idea what’s wrong?
Hi @popmouth
Perhaps you could post a screenshot of the field groups in question and also the edit screen where they are showing?
Of course, sorry, should’ve done that right away. However I’m using a swedish version of wordpress, also I zoomed out a bit for better overview just so you know.
thanks for your time!
Hi @popmouth
I was hoping to see the location rules, but you have hidden them…
Can you please show them in the screenshot (screenshot 2).
Also, have you checked your console log for any errors in the edit screen (screenshot 1)?
Sry, here is a new picture of that: “รคr lika med” is Swedish for “same as” FYI.
Yes, I can’t find any errors
EDIT: I am getting something under “All” (not errors) in the console log (using Firebug for Firefox)
The file it’s regarding is: POST http://utt.se/wp-admin/admin-ajax.php
The code showing: {“wp-auth-check”:true,”wp-refresh-post-lock”:{“new_lock”:”1377241874:1″},”server_time”:1377241874}
The file keeps on reloading and reloading
Hi @popmouth
If you trash the field group, does it still appear?
Have you tried removing all the location rules? Does is still appear then?
I tried to delete a field group, and that removes it from the edit page. However changing the location rules does nothing, and only one of my fields loads correctly on one of my pages (in editing mode)
Edit: I got the rules working, by chaning around the settings and updating the group. Now they load correctly on the pages I set the rules for, however each field group that I have created, and shouldn’t appear on edit screen appears anyways, but never completes load (as seen on screen shot).
ps. this is obviously a lesser problem, since now I can at least use the custom fields :), however it would be neater for my customer if they showed correctly
Hi @popmouth
Is it possible that you have a duplicate field group registered via PHP in your functions.php?
I couldn’t find any duplicate, this is my functions.php file, is anything else weird in there?
Also I’m experiencing great problems echoing the custom field value into a variable. I am using a Field name of “textbild” Here is the code:
<div class=”contentCon clearfix”>
<?php global $post;
$id = ‘4’; //set the post id here
$thePost = get_post($id); //get the post
setup_postdata($thePost); //setup the post
$textbild = get_post_meta($post->ID,’textbild’, true);
?>
<h2><?php echo get_the_title($ID = ‘4’); ?></h2>
<div class=”contentText”><?php the_content(); ?></div>
“/>
</div>
I’ve also tried:
$textbild = the_field($post->ID,’textbild’, true);
&
$textbild = get_field($post->ID,’textbild’, true);
Thanks for your time mate!
Hi @popmouth
Your code shows no signs of any registered field groups via PHP. I am curious as to why you attached your functions.php screenshot, are you not sure what I mean by my question?
As for your code, there are quite a few issues with it, most of all is that your setup_postdata function will not work due to the name of the variable. It must be called $post, not $thePost.
No I understood what you meant, and couldn’t find the duplicate, was just curious if there was anything else in the functions.php that caused the problem.
And changing $thePost seemed to do it for me ๐ cheers!
I still seem to have problems though with the location rules ๐
Dear Elliot,
I have the same problem than popmouth,
ACF version : 4.2.2
Wordpress version : 3.6
I was working but then I got a problem (too many custom fields, we are working on a website with a lot of templates).
Now when I change the location rules, and save, nothing change and it stays on “post type” > “post”
I tried to remove, change, add etc. nothing change.
Could you please say me what could be thet problem and also where I can find it in the database to change it manually? I really need it shortly cause website is on production
Thanks in advance,
Cyril
Hi @cleocq
Sounds like you have a slightly different issue and that is you are running out of PHP memory or hitting a max_vars limit during the save function.
I would check your server logs for any errors which can help determine the issue
The topic ‘Location rules not working’ is closed to new replies.
Welcome to the Advanced Custom Fields community forum.
Browse through ideas, snippets of code, questions and answers between fellow ACF users
Helping others is a great way to earn karma, gain badges and help ACF development!
We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Privacy Policy. If you continue to use this site, you consent to our use of cookies.