Creating a list with multiple categoreis and options
Creating a list with multiple categoreis and options
Creating a list with multiple categoreis and options
The trick is to call the hook “wp_insert_post“. But the post-type is not what you expect – post, page oder custom post type. It’s “revision”. Now you can fire a WP_Query right after the post is saved in the database.
According to ACF Docs on Get values from an options page. You should use ‘option’ not ‘options’ as the second parameter to the have_rows() function. <?php if( have_rows(‘repeater’, ‘option’) ): ?> <ul> <?php while( have_rows(‘repeater’, ‘option’) ): the_row(); ?> <li><?php the_sub_field(‘title’); ?></li> <?php endwhile; ?> </ul> <?php endif; ?>
Reading the docs (never used flexible fields, only repeater fields, but look the same): <?php // check if the flexible content field has rows of data if( have_rows(‘flexible_content_field_name’) ): // loop through the rows of data while ( have_rows(‘flexible_content_field_name’) ) : the_row(); if( get_row_layout() == ‘paragraph’ ): the_sub_field(‘text’); elseif( get_row_layout() == ‘download’ ): $file = … Read more
If I compare the counter to five instead of the input (****), then it evaluates perfectly. Thanks to Milo for the help. <?php if( have_rows(‘program_skills’) ) : while( have_rows(‘program_skills’) ) : the_row(); ?> <div class=”skills-wrapper”> <div class=”col-xs-6″> <p><?php the_sub_field(‘heading’); ?></p> </div> <div class=”col-xs-6″> <div class=”skills-graph”> <ul> ****<?php for($i=1; $i<=5; $i+=1) if( $i <= get_sub_field(‘rating’) ) … Read more
Get month and day from a Date Picker custom field
All I can think is to process the posts at an earlier stage with a Core hook. This is crude, of course, but: function hack_the_post($posts) { foreach ($posts as $p) { $p->post_content .= ‘ I added this’; } return $posts; } add_action(‘the_posts’, ‘hack_the_post’); It is a bit energy intensive but so long as your plugin/theme … Read more
Might be a stupid question, but have you tried creating the Custom Taxonomies using the GUI via the plugin? I only ask because I recently had problems creating custom taxonomies for a restaurant website via php functions. I could only get it to work if I used the GUI.
I played with the code for a bit longer and managed to get it working. Answer below add_filter( ‘gform_pre_render’, ‘freetrial_studios’ ); add_filter( ‘gform_pre_validation’, ‘freetrial_studios’ ); add_filter( ‘gform_pre_submission_filter’, ‘freetrial_studios’ ); add_filter( ‘gform_admin_pre_render’, ‘freetrial_studios’ ); function freetrial_studios( $form ) { foreach ( $form[‘fields’] as &$field ) { if ( $field->type != ‘select’ || strpos( $field->cssClass, ‘studio-list’ ) … Read more
One option is to fetch all of the posts to a single array and filter that array 50 ways. This would only generate the one query: $posts = get_posts(array( ‘posts_per_page’ => -1, ‘post_type’ => ‘school’ )); To filter your array you would do something like this: $this_state = “Texas”; $state_posts = array_filter($posts, function($results) use($this_state) { … Read more