Hi @BeeBlu
I just noticed the problem!
Change:
<img src="<?php echo $images[0]["url"]["large"]; ?>" >
To
<img src="<?php echo $images[0]["sizes"]["large"]; ?>" >
Remember to always debug your code, and read the docs.
Thanks
E
Hi @BeeBlu
This debug info prooves that the images are being loaded. So you can use this in your code as you previous had:
<?php
$images = get_field('gallery');
?>
<!-- Image here -->
<img src="<?php echo $images[0]["url"]["large"]; ?>" >
Hi @edwin
I think you can edit the global $wp_query
object to modify the number of results and the actual results found.
But perhaps the easiest solution of all is to use a taxonomy for the ‘status’ this way you can separate it form the meta_query.
Thanks
E
Hi @Exelmans Graphics
The biggest hurdle for this feature is getting it to work with a multi-select field. I just can’t see a way to include an edit button for each item.
Sorry, but thanks for the request.
Thanks
E
Hi @faeronsayn
Sorry, but I don’t fully understand your question.
Now I want these fields to appear on their post edit pages using ACF. How can I do this?
Please be very descriptive and clear.
Thanks
E
Hi @andisaleh
Thanks for your reply, but I am still really struggling with this. Not sure where that code you provided should go. Where would it fit in relation to my full query/code here…
<?php
$args=array(
'post_type' => 'book',
'post_status' => 'publish',
'posts_per_page' => 12,
'caller_get_posts'=> 1,
'orderby'=> 'date',
'order' => 'DESC'
);
$my_query = null;
$my_query = new WP_Query($args);
if( $my_query->have_posts() ) {
echo '';
$i = 0;
while ($my_query->have_posts()) : $my_query->the_post();
if($i % 6 == 0) { ?>
<div class="row">
<?php
}
?>
<img src="<?php the_field('cover_image'); ?>" /><br />
<?php the_field('author_name'); ?><br />
<?php the_title(); ?><br />
</div>
<?php
if($i % 6 == 0) { ?>
<?php
}
$i++;
endwhile;
}
wp_reset_query();
?>
Any help appreciated.
Thanks for your replies!
It will be a great feature if you include it in the future.
Meantime, I have managed with a text field, where the client manually types different dates, separated by commas (which later will appear in an array inside a jquery script)
Thanks again,
Victor
I tried another approach – I get all posts and than I filter those that is right into one array and all others into another array. Is in fact better for my purposes. I have this code:
$arenden = new WP_Query( $args );
if ( $arenden->have_posts() ) :
while ( $arenden->have_posts() ) : $arenden->the_post();
$utfors_av = get_field('utfors_av');
$utfors = reset($utfors_av);
if($utfors == $user_id) {
array_push( $idmina, get_the_ID() );}
endwhile;
endif;
?>
The $args is just the standard, $idmina is the array I have setup were I want to store the IDs. But when I use this, I get an error:
Warning: reset() expects parameter 1 to be array, boolean given in ../archive-arenden.php on line 42
Line 42 is $utfors = reset($utfors_av).
When I use this on line 42 instead:
$utfors = strstr($utfors_av, ',', true);
I get another error saying it is an array.
Warning: strstr() expects parameter 1 to be string, array given in /home/almewebb/alpnet/wp-content/themes/enterprise-pro/archive-arenden.php on line 42
So what do I do wrong. Surely something trivial that I don’t see.
Hi, thank you for your response..
I tell you what you ask me..
My custom post type is ‘pacchetto’ and i have two group for each post type. One for the wordpress posts: and one for my custom post type:
I want a query with CPT’s posts ‘pacchetto’ in sigle.php where return the posts when fields ‘zona_per_gli articoli’ = ‘zona-per-i-pacchetti’
I use the follow code:
<?php
$zone_articoli = get_field('zona_per_i_pacchetti');
$args = array(
'post_type' => 'pacchetto',
'meta_query' => array(
'key' => 'zona_per_gli_articoli',
'value' => $zone_articoli
);
$loop = new WP_Query($args);
while ( $loop->have_posts() ) : $loop->the_post(); ?>
<div>
<h2><a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>"><?php the_title(); ?></a></h2>
</div>
<?php endwhile; wp_reset_postdata();?>
This code return me all posts from CPT ‘pacchetto’ and not filtering with fields. I think because i am in single.php and there are a rules for each post type
In effect if i write
echo $zone_articoli
it return the effective value, but if i write
$zone_pacchetti = get_field('zona_per_gli_articoli');
echo $zone_pacchetti;
don’t work (no value).
This last code work in single-pacchetto.php
I think i must merge the location rules for make my query with my fields…
Thank you so much!
I’m not sure what I’m doing wrong: http://colbyblogs.org/wptest/custom-post-types/shortcode/
On this page I’m using a plugin called CSS & Javascript Toolbox to inject PHP code on my page, if you look at the source code the img tag isn’t working right with the code I took from your help pages:
<img src="<?php the_field('field_name'); ?>" alt="" />
Hi elliot – thank you so much! Amazing support here!
Note: these changes should also be made to the right side of the UI on line 495, although a little different:
changing:
$title .= $p->post_type;
To:
$post_type_object = get_post_type_object( get_post_type( $p ) );
$title .= $post_type_object->labels->singular_name;
And also in the “select”, where you can select a posttype. Current code looks like this around line 451:
foreach( $field['post_type'] as $post_type )
{
$choices[ $post_type ] = $post_type;
}
Im not completely sure what the best way would be here, as i don’t quite understand the acf filters.
But that should then fix it for this field, i think. Im impressed with the quick response!
For “media modal window” I mean the default modal-box that WordPress show when a user have to upload a image or a file in a post. The same that the Gallery Field show when I click the “upload image” blue button.
If I select a pre-existing image in Media the gallery works and display them right in the admin and in the front-end.
If i upload a new image, it is correctly uploaded and show in the gallery-field box BUT when I save the post or when i update the post… the last uploaded image disappear and the pre-existing images remain correctly in the gallery.
I see that the new image is correctly uploaded in the website, i can see it in the Media section.
The field have unique name, and it work for long time until now.
Other ACF for the same post-type works great.
The unique major change I made in the website is enable WPML.
Any ideas?
I am doing this inside a template (archive). I updated my code with WP_Query
<?php $user_id = get_current_user_id();
echo $user_id;?>
<?php $$args = array(
'post_type' => 'arende',
'meta_key' => 'utfors_av',
'post_status' => 'publish',
'posts_per_page' => -1,
'order' => 'ASC',
'meta_query' => array(
array(
'key' => 'utfors_av',
'value' => $user_id, //array
'compare' => '=',
)
)
);
$query = new WP_Query($args);;?>
But this returns the same result as mine did before.
Hi @thesrpr
If you reduce 200
down to 50
, does this fix the issue? It is possible that your server can’t handle querying 200 posts at once.
Thanks
E
Also, I just noticed you are performing a meta_query, not a normal WP query.
I think you need to create a WP_Query
that contains a meta_query param.
Thanks
E
Hi @ramon
Please check that your $ids array is correct by debugging it like so:
<?php echo '<pre>';
print_r( $ids );
echo '</pre>';
die; ?>
Looking at your code, it seems to be a jumble of WP_Query
and get_posts
.
Please keep to 1 consistent style like so:
<?php
$ids = get_field('relacionado', false, false);
$the_query = new WP_Query(array(
'post_type' => 'produtos',
'posts_per_page' => 3,
'post__in' => $ids,
'post_status' => 'any',
'orderby' => 'rand',
));
// The Loop
if ( $the_query->have_posts() ):
while ( $the_query->have_posts() ): $the_query->the_post();
?>
<div>
<img src="<?php echo get_field('imagem_chamada'); ?>" alt="">
<h2><a href="<?php the_permalink() ?>" title="" rel="bookmark"><?php the_title() ?></a></h2>
<p><?php echo get_field('chamada'); ?></p>
</div>
<?php
endwhile;
endif;
?>
It is possible that you don’t even need to use a custom WP_Query at all. Have you tried looping over the results from get_field('relacionado')
?
Thanks
E
Hi @Boniz
Can you please explain what you mean by:
‘It disappear both in the Gallery Field metabox and in the “Media modal window” view!’ – what is ‘it’?
Do you have any other fields on the page which are saving to the same field name as your gallery field’s?
perhaps you could try renaming your gallery field to something unique to test this?
Are any other ACF fields saving correctly?
Thanks
E
Thanks for your feature request. Currently ACF uses the native search found in the WP_Query parameter.
To search the_content, you can always hook into the relationship args and customize the query yourself.
I don’t want to add any custom search functionality to this field due to the interface not showing the highlighted ‘search terms’.
Thanks
E
two things to try:
$args = array('ppp'=>200);
and see if you can just go through the filter with no changes. if not, find the errors, they are either in your javascript console or hiding in your error log (in local do you have wp_debug set to true?)acf/fields/relationship/result/name={$field_name}
if you have multiple fields to query against, i wonder if you can dogpile them:
add_filter('acf/fields/relationship/name=title', 'tdr_carousel_query', 10, 3);
add_filter('acf/fields/relationship/name=keywords', 'tdr_carousel_query', 10, 3);
add_filter('acf/fields/relationship/name=description', 'tdr_carousel_query', 10, 3);
function tdr_carousel_query( $args, $field, $post )
{
$args = array(
'posts_per_page' => 200
);
return $args;
}
add_filter('acf/fields/relationship/query', 'tdr_carousel_query', 10, 3);
no on screen errors. just when you start typing in the search box nothing happens. When I remove the above code it works just fine.
Production and local
Hi @anarita
Currently, WP does not provide a termmeta table, so a meta query cannot be performed on a term query.
What I would do is load all terms from the ‘project’ taxonomy, then loop over them and load in the ‘client’ for each one using the get_field
function.
You can then simply compare the value, and continue
the loop to avoid it, or display the project data if a match was found.
Thanks
E
Hi @pastore1980
Your question is quite hard to understand. Can you please provide a clearer explanation of what you are trying to do?
Please name your CPT instead of saying I have one custom post type
.
Also, please refrain from such broad and vague terminology like this:
Now i want use the value of field from custom type (with a new wp-query loop) in single.php
I can tell you that the get_field function can be used WITHIN a custom WP_Query loop.
What code are you using? Perhaps you can post it (please wrap in backticks – code button)
Hi @tuhin
Thanks for your concern. All servers have a limit of how many PHP variables can be used at one time, and how big an array variable can be.
Your repeater field is perhaps the larges I have ever seen, and this field was not intended to be used in this manor.
ACF does not contain a limit, but PHP does. It is possible to increase this max_vars
limit and PHP memory
like so:
http://www.advancedcustomfields.com/resources/faq/losing-data-save/
Thanks
E
Hi @tomjhume
Using get_sub_field
within this load_field filter will not work.
The get_sub_field function MUST be used within a have_rows
while loop.
Perhaps there is more to your question that originally mentioned?
What are you trying to do? What is your data setup?
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.