Agreed, it would be very helpful to have this documented on ACF Group Field page or have clear link on that page to nested groups in have_rows()
https://www.advancedcustomfields.com/resources/have_rows/
@gregory @sherriff
thanks for code, and for asking the question . I don’t get where this fits either
Height of wysiwg is hardcoded in wysiwyg.php
Path\wp-content\plugins\advanced-custom-fields-pro\fields\wysiwyg.php:
255
256 // get height
257: $height = acf_get_user_setting('wysiwyg_height', 300);
258: $height = max( $height, 300 ); // minimum height is 300
You can’t easily change that with css because it produces inline css , viz –
<textarea id="acf-editor-gtg6gtg6gtg62" class="wp-editor-area" name="acf[field_gtg6gtg6gtg62]" style="height:300px;">wysiwyg content here</textarea>
Good thing is that wysiwyg.php looks like its primed to go for adding wysiwyg height via admin interface.
working now thanks.
Using ACF functions within get_posts (and maybe all functions?) means there has to be an explicit post ID passed to the ACF functions, so above works if $post->ID added
eg
if(get_field('values_and_outcomes', $post->ID))
while(has_sub_field('values_and_outcomes', $post->ID))
get_sub_field($fieldname, $post->ID)
etc
ok, fair enough.
what i do want to be sure of is –
can i use get_posts with repeater subfields when working with more than one post?
OR do i HAVE to use $wpdb
similar to this example:
http://www.advancedcustomfields.com/resources/tutorials/querying-the-database-for-repeater-sub-field-values/
thanks
seems i have to do this using $wpdb …
//average for all of post_type by assessor
function q_average_assessor( $fieldname, $posttype, $assessor) {
global $wpdb;
$repeaterfieldname = 'values_and_outcomes_%_' . $fieldname;
// get all rows from the postmeta table where post_type = $postype AND has a repeater subfield of $fieldname
// - http://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results
$rows = $wpdb->get_results($wpdb->prepare(
"
SELECT *
FROM wp_postmeta
INNER JOIN wp_posts ON ( wp_posts.ID = wp_postmeta.post_id )
WHERE wp_posts.post_type=%s
AND wp_postmeta.meta_key LIKE %s
",
$posttype,
$repeaterfieldname
));
$coreval = 0;
$counter = 0;
// loop through the results
if( $rows )
{
foreach( $rows as $row )
{
// for each result, find the 'repeater row number' and use it to load the image sub field!
preg_match('_([0-9]+)_', $row->meta_key, $matches);
$meta_key = 'values_and_outcomes_' . $matches[0] . '_' . $fieldname; // $matches[0] contains the row number!
// use get_post_meta
$thisassessor = get_post_meta( $row->post_id, 'assessor', true );
if($thisassessor == $assessor) {
$counter++;
$coreval = $coreval + get_post_meta( $row->post_id, $meta_key, true );
}
}
}
$paverage = $coreval / $counter;
$average = round($paverage, 1);
return $average;
}
but means a lot of my previous code is wrong. assumption is that for a query on an archive page (ie involving more than one post and repeater fields) get_posts() doesn’t work but $wpdb does?
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 Cookie Policy. If you continue to use this site, you consent to our use of cookies.