Hi Elliot,
The only sortable in the post-new.php file is in this script line
<script type='text/javascript' src='http://www.tailsweliveby.com/wp-admin/load-scripts.php?c=1&load%5B%5D=jquery-core,jquery-migrate,utils,jquery-ui-core,jquery-ui-widget,jquery-ui-mouse,jquery-ui-sortable,underscore,backbone,wp-util,&load%5B%5D=wp-backbone,media-models,plupload,plupload-html5,plupload-flash,plupload-silverlight,plupload-html4,json2,wp-plupload,media-view&load%5B%5D=s,quicktags&ver=3.6.1'></script>
jquery-ui-sortable is there but I don’t know if that is what you are looking for.
Also, I added a relationship field and the sorting doesn’t work. I also took off the content editor so it wouldn’t display incase it was a plugin adding a button to the visual editor but that didn’t make a difference.
I’ve disabled all the plugins and changed theme to default Twenty Twelve but still had the issue. That ruled out functions I have in my child theme.
It’s the Logged in User in the location rules that is causing the issue. When I don’t have that rule it works. It’s baffling but has to be something I am doing. Ugh.
I’m going to try and work this the other way. I’m going to build the site up from a clean single install and see if I still have the problem.
I’ll let you know if it works.
Ellen
Hi @JiveDig
I would use WP taxonomies for this. A taxonomy is very light weight and can quickly be added / edited.
Create each song name / artist name as a taxonomy term (use 2 separate taxonomies)
In short, ACF won’t help you out much on this project. I would jump over to the stack exchange forum for nay further WP help
Good luck
Cheers
E
Hi @prabhu
Be sure to check your console log to see if any ERROR is returned in the AJAX call during upload.
Your next step is to search this forum / google for some existing threads which cover how to edit the user privileges to allow the user to upload.
Also, you may find you have a security plugin which is stopping the upload script from being accessed from the front end. This will require some debugging / detective work to find out what’s wrong and find a solution.
Good luck.
Thanks
E
Hi @oscarf
I haven’t had much experience with CRMs before, but hopefuly someone else can answer this.
Just incase no one does, perhaps post this question on a more general WP forum such as stack overflow.
Thanks
E
Hi @phil.owen
Aah, I see the problem now. The $post_id param is wrong.
You need to create a string like this "user_{$user_id}"
;
So perhaps $other_page
should be 'user_' . $current_user->ID
?
Good luck
Thanks
E
Hi @juhoaj
Sounds like all you need to do is create multiple pages in the backend of WP. Each page represents a ‘section’.
Then create a page called ‘Home’ and create a custom page template called ‘home’ for this page to use. Now edit this page template:
1. Use the WP_Query object to find all pages, then, loop through them.
2. For each page (post) you loop through, use the $post->ID to find the ACF data.
Read up on the get_field function to see how you can load data from a specific ID.
Thanks
E
Perhaps you could post the error you see?
Perhaps you could also research into debugging techniques to understand what it is your nee to achieve.
Thanks
E
Solved it by myself
<?php
$field = get_field_object('field_52385b5083a0d');
$value = get_field('field_52385b5083a0d');
$label = $field['choices'];
foreach( $label as $key => $value ){?>
<?php $test_meta = array(
'orderby' => 'id',
'order' => 'ASC',
'category' => $cat_id, //Get the current cat (Category.php)
'meta_key' => 'serien',
'meta_value' => $key,
'meta_compare' => 'LIKE'); // With the like i get a link from the meta-key-value to the sql-meta-value
$test_posts = get_posts( $test_meta);
if(count($test_posts) < 1){
}
else{
?>
Okay, so I’ve sussed it, it took a while. The two main problems I encountered were:
bloginfo
as opposed to get_bloginfo
which returns a variable.Here’s the final code which works a treat.
<?php
$template_directory = get_bloginfo('template_directory');
$rows = get_field('slider_image');
shuffle ($rows);
if($rows)
{
foreach($rows as $row)
{
echo $row['the_caption'] . '<img src="' . $template_directory . '/logo_' . $row['logo_colour'] . '.png" />'. PHP_EOL;
}
}
?>
Thank you so much Nuro for all your help, I wouldn’t of got there without your assistance.
I’m off to the pub now!
Hello, I am trying to save user metadata from a form. I use the plugin WP User Frontend to store normal user data at front. The problem is that i can’t save my extended user metadatas.To display the extended fields all goes well, I have a template with the code indicated ..
I wonder what hook to use to call the function with the “do_action (‘acf / save_post’)”.
I guess the only function has to make the call to the hook.
Will this new role I can invoke it from the “functions.php”?
I tried the wordpress hooks but I can’t find adequate, on the other hand, does the hook has to be necessarily during the process? Can be just following standard data saving a user?
I have tried many things already and nothing works for me, thank you very much.
Okay so this almost worked… it outputted the following
http://domain.com/template-directory
<ul>
<li>Caption 1</li>
<li>[img src="logo_Grey.png" ]</li>
<li>Caption 2</li>
<li>[img src="logo_Grey.png" ]</li>
<li>Caption 3</li>
<li>[img src="logo_White.png" ]</li>
</ul>
No random order unfortunately, no real progression from my original (revised) code.
<?php if(get_field('slider_image')): ?>
<?php while(has_sub_field('slider_image')): ?>
<?php the_sub_field('the_caption'); ?>
<img src="<?php bloginfo('template_directory'); ?>/logo_<?php the_sub_field('logo_colour'); ?>.png" />
<?php endwhile; ?>
<?php endif; ?>
Once again thank you for persevering!
Ah think it makes sense now… forgive my previous mistakes, was confused about your objective ๐
So I think I get it know:
You enter each caption and then choose a color corresponding to that caption right? So you enter caption 1 and choose the image for that caption to be grey.
In that case, this is what you want to do:
<?php
$template_directory = bloginfo('template_directory');
$rows = get_field('slider_image');
if($rows) {
echo '<ul>';
$i = 0;
while(has_sub_field('slider_image')) {
$field = get_sub_field_object('logo_colour');
$value = get_sub_field('logo_colour');
$label = $field['choices'][ $value ];
echo '<li>' . $rows[$i]['the_caption'] . '</li>';
echo '<li><img src="'. $template_directory . '/logo_'. $label . '.png" /></li>';
$i++;
}
echo '</ul>';
}
?>
Hi Nuro,
The code didn’t work unfortunately, but I think you’ve already started thinking of alternatives…
Yes the caption is just a text field. The entry is usually a single word.
Colour type is indeed a select drop-down containing two entries at the moment… grey or white.
I was just thinking myself if we could eliminate the “if” statement, by just using the field…
I’ve just changed the original code to:
<img src="<?php bloginfo('template_directory'); ?>/logo_<?php the_sub_field('logo_colour'); ?>.png">
And all seems to work.
I hope this makes it easier.
This is the updated code:
<?php
$rows = get_field('slider_image' );
$sub_field = has_sub_field('slider_image');
$rand_row = $rows[ array_rand( $rows ) ];
$logo_colour = get_sub_field('logo_colour');
$caption = get_sub_field('the_caption');
$template_directory = bloginfo('template_directory');
if($rows) // if slider_image exits
{
echo '<h3>Header</h3>';
echo '<ul>';
while($sub_field) // enables us to use get_sub_field
{
$rows = $rand_row['slider_image']; // random order of rows
foreach ($rows as $row) {
echo '<li>' . $caption . '</li>'; // displays caption
if(($logo_colour) == "white") { // displays white logo if selected, else grey
echo '<li><img src="'. $template_directory . '/logo_white.png" /></li>';
} else {
echo '<li><img src="'. $template_directory . '/logo_grey.png" /></li>';
}
}
echo '</ul>';
}
}
?>
I think I’ve sorted it… there was one too many ) and we were one } short.
<?php
$rows = get_field('slider_image' );
$sub_field = has_sub_field('slider_image');
$rand_row = $rows[ array_rand( $rows ) ];
$logo_colour = get_sub_field('logo_colour');
$caption = get_sub_field('the_caption');
$template_directory = bloginfo('template_directory');
if($rows) // if slider_image exits
{
echo '<ul class="invisible">';
while($sub_field) // enables us to use get_sub_field
{
$rows = $rand_row; // random order of rows
foreach ($rows as $row) {
echo '<li>' . $caption . '</li>'; // displays caption
if (($logo_colour) == "White") { // displays white logo if selected, else grey
echo '<li><img src="' . $template_directory . '/logo_white.png" /></li>';
} else {
echo '<li><img src="' . $template_directory . '/logo_grey.png" /></li>';
}
}
}
echo '</ul>';
}
?>
It’s difficult to test as the site is live but I’m going to have a go now!
Thanks again!
This should work. Put it in a list for now, will have to change that.
<?php
$rows = get_field('slider_image' );
$sub_field = has_sub_field('slider_image');
$rand_row = $rows[ array_rand( $rows ) ];
$logo_colour = get_sub_field('logo_colour');
$caption = get_sub_field('the_caption');
$template_directory = bloginfo('template_directory');
if($rows) // if slider_image exits
{
echo '<h3>Header</h3>';
echo '<ul>';
while($sub_field) // enables us to use get_sub_field
{
$rows = $rand_row; // random order of rows
foreach ($rows as $row) {
echo '<li>' . $caption . '</li>'; // displays caption
if(($logo_colour) == "white")) { // displays white logo if selected, else grey
echo '<li><img src="'. $template_directory . '/logo_white.png" /></li>';
} else {
echo '<li><img src="'. $template_directory . '/logo_grey.png" /></li>';
}
}
echo '</ul>';
}
?>
Sorry Nuro, this is probably me being awful at explaining things.
Say at the moment the code is pumping out:
Three separate entries. Logo colour defined and fixed to the caption.
I want it to pump out something like:
OR
OR any random order really. Notice the caption and the logo colour remain the same so it’s just jumbling up the order of the entries not the contents within each entry.
So in essence something like:
<?php if(get_field('slider_image')): ?>
<RANDOM ORDER>
<?php while(has_sub_field('slider_image')): ?>
<?php the_sub_field('the_caption'); ?>
<img src="<?php bloginfo('template_directory'); ?>/logo_<?php if(get_sub_field('logo_colour') == "White") { echo 'white'; } else { echo 'grey'; }?>.png" />
<?php endwhile; ?>
<?php endif; ?>
Flippin’ eck I’m terrible at this stuff.
Hi Nuro, thanks for taking a look.
In answer to:
Do you want the โelseโ color to be random?
No I only want the order of the rows to be random.
That was the issue, or at least part of it.
I had all the posts already created when I add the radio button to my order_block ACF group and for some reason, it just stopped passing the value: thought maybe it was naming (product_category); thought it was because all the posts already existed…
As soon as I changed it to a checkbox, everything came back, so I’m not really sure what’s going on.
Thanks for the quick response and great plugin! Nice parallax btw!
Greg
yeah thanks got it but i get another questions – how can i get a bridge between the keys and labels? so for example in the foreach
foreach( $label as $key => $value )
{
echo $key . ', ';
}
i want to echo so label as well as the key?
Hi @herrfischer
This is what you need to do:
1. Create a select field with the options
2. Write some jQuery to trigger a function on change of this select
3. Get the JS function to do an AJAX call to a WP ajax function
4. Create this WP ajax function in your functions.php
5. Get your JS to post the selected value to the php function
6. Get your php function to use this value to filter the posts and return the correct data
7. Get your js function to use this data on complete.
You will find a tutorial in the docs on querying the posts based on a custom field value, the rest is up to you and google.
Thanks
E
Hi, i’ve use update_field function but the data are not saved correctly, i’ve load my image with wp.uploadFile RPC Query and get the ID METADATA by $response[‘id’] with wp_get_attachment_metadata function; now i’ve create the array containing id, title, caption, url, sizes and so on… after that i’ve this code:
$value = get_field("field_5234c710a5b38", $post_id);
$value[] = $arrayPhoto;
update_field( "field_5234c710a5b38", $arrayPhoto, $post_id );
After that the gallery are empty, into db i see the field into wp_postmeta are different as a manual load, i’ve a metakey gallery (field_5234c710a5b38) with the serialized arrayPhoto (a:13:{i:0;a:9:{s:2:”id”;i:2272;s:3:”alt”;s:0:””;s:5:”title”;s:20:”import_1513072……), into other field generated by wordpress there are a serialized object with the ID of two metakey (_wp_attached_file and _wp_attachment_metadata) with the array of data (a:1:{i:0;s:4:”2182″;}).
How can i fix it?
Thanks
Awesome Elliot, that sounds good. Looking forward to resolving it!
Appreciate your quick reply.
-M
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.