
got it (it is explained here: http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/ and here is the user_query explained: http://codex.wordpress.org/Class_Reference/WP_User_Query):
<?php
// args
$args = array(
'meta_query' => array(
'relation' => 'OR',
array(
'key' => 'country',
'value' => 'germany',
'compare' => 'LIKE'
)
)
);
// The Query
$user_query = new WP_User_Query( $args );
// User Loop
if ( ! empty( $user_query->results ) ) {
foreach ( $user_query->results as $user ) {
echo '<p>' . $user->display_name . '</p>';
}
} else {
echo 'No users found.';
}
?>
<?php
// aaaaaand reset ...
wp_reset_query();
?>

Think i need an example like here:
http://www.advancedcustomfields.com/resources/how-to/how-to-query-posts-filtered-by-custom-field-values/
but with a “checkbox” field.

Okay i get the field this way:
<?php echo implode(', ', get_field('country', 'user_'. $user_id )); ?>
but how do i filter the loop with this field?

how to even get the data of a checkbox field with a wp_user_query? i tried
<?php echo implode(', ', get_field('country', $user_id )); ?>
as mentioned in http://www.advancedcustomfields.com/resources/field-types/checkbox/ but it shows me nothing :-/ in a normal query it works.


great, thanks that works 🙂
<?php if(get_field("downloads")): ?>
<div id="downloadbox">
<h3>Files</h3>
<ul class="downloads">
<?php while(the_flexible_field("downloads")): ?>
<?php if(get_row_layout() == 'flexible_download'): // layout: Content ?>
<?php $attachment_id = get_sub_field('file');
$url = wp_get_attachment_url( $attachment_id );
$title = get_the_title( $attachment_id );
// part where to get the filesize
$filesize = filesize( get_attached_file( $attachment_id ) );
$filesize = size_format($filesize, 2);
// part where to get the extension
$path_info = pathinfo( get_attached_file( $attachment_id ) );?>
<li class="cf dlbox">
<a href="<?php echo $url; ?>" class="cf">
<span class="dl-title"><?php echo $title; ?><small><nobr><strong>Size:</strong> <em>(<?php echo $filesize; ?>)</em></nobr></small></span>
<span class="dl-extension"><span class="dl-extension-inner"><?php echo $path_info['extension']; ?></span></span>
</a>
</li>
<?php endif; endwhile; ?>
</ul>
</div>
<?php endif; ?>

glad it works!

this way i get the title of the parent page, maybe the code helps you:
<?php if(is_page()):
$toppage=array_reverse(get_post_ancestors($post->ID));
if($toppage[1]){
echo '<h1 class="site-title">'.get_the_title($toppage[1]).'</h1>';
}
endif;
?>

got it working now:
<?php
$temp = $wp_query;
$wp_query= null;
$wp_query = new WP_Query();
$wp_query->query('cat='.(get_field('jobs_kategorie')).'&paged='.$paged .'&showposts=1' .'&post_type=stellenangebote' ); ?>

how to check if one image or more? (echo “1 picture” / “2 pictures“)

okay now i figured out i just had to replace the “$url” so it has to look like:
<?php echo $image['sizes']['thumb-180']; ?>
😀 it was so near i haven’t seen it. i thought it’s too easy 😛


finally got it:`
<?php $attachment_id = get_field('download');
$url = wp_get_attachment_url( $attachment_id );
$title = get_the_title( $attachment_id );
// part where to get the filesize
$filesize = filesize( get_attached_file( $attachment_id ) );
$filesize = size_format($filesize, 2);
// show custom field
if (get_field('download')): ?>
<a href=”<?php echo $url; ?>” ><?php echo $title; ?></a>
<!– show filesize –>
<?php echo $filesize; ?>
<?php endif; ?>
`
🙂 <- happy

this way i get a size:
<?php $attachment_id = get_field('download');
$url = wp_get_attachment_url( $attachment_id );
$title = get_the_title( $attachment_id );
if (get_field('download')): ?>
<a href="<?php echo $url; ?>" ><?php echo $title; ?></a>
<?php
$file_size = $attachment_id; echo size_format($file_size, 2); ?>
<?php endif; ?>
but its not the size of the file it’s always about 1kb, i think it’s the size of the “ID” itself? i get the title with “get_the_title” but how do i get the size in MB?

hi elliot, thanks, i know this thread – wordpress tells me how to display the filesize: http://codex.wordpress.org/Function_Reference/size_format – but how do i GET it?

thank you very much, now this works:
<?php
global $wp_query;
$postid = $wp_query->post->ID;
echo get_post_meta($postid, 'country', true);
?>
<?php $country = get_post_meta($post->post_parent, 'country', true);
echo $country;
?>
<?php
global $post;
$parent = $post->post_parent;
$grandparents = get_ancestors( $parent, 'page');
$country = get_field( 'country', $grandparents[0] );
echo $country;
?>

searched the forum and i think it is not possible for custom fields. the search does what i want but only if the searched word is no custom field entry. means he can not show the custom field searched word highlighted in the search excerpt.

hello,
i ticked the option “Create custom search result snippets” and at “Length of the snippet” i have 200 characters. but when i have a page with the text
Sowohl Überschriften, Absatz- und Zeichenanzahl als auch Themenbereiche lassen sich auswählen und entsprechend den Bedürfnissen der Publikation anpassen, für den der Text vorgesehen ist. Die optische Wirkung von größeren Textmengen in verschiedenen Schriftarten und Ausrichtungen lässt sich innerhalb von Minuten prüfen, was beispielsweise bei der Herstellung von Büchern oder Broschüren sowohl für den Setzer als auch für den Kunden von Vorteil ist.
this are 300 characters. so i want the search result for “Broschüren” like
… in verschiedenen Schriftarten und Ausrichtungen lässt sich innerhalb von Minuten prüfen, was beispielsweise bei der Herstellung von Büchern oder Broschüren sowohl für den Setzer als auch für den Kunden von Vorteil ist.
but at the moment it is like:
Sowohl Überschriften, Absatz- und Zeichenanzahl als auch Themenbereiche lassen sich auswählen und entsprechend den Bedürfnissen der Publikation anpassen, für den der Text vorgesehen ist. Die optische Wirkung von größeren Textmengen in verschiedenen …
sadly the searched word “Broschüren” is not shown …

sorry double post …
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.