Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

New answers tagged

1

Try this: $total = 0; while(have_rows('repeater')) : the_row(); $space_avail = (int)get_sub_field('space_avail'); $total += $space_avail; endwhile; echo $total;


0

Remove: the_sub_field('space_avail' ); This display's the string values. acf documentation repeater fields // loop through the rows of data while ( have_rows('repeater_field_name') ) : the_row(); // display a sub field value the_sub_field('sub_field_name'); so final code should be: <?php $total = 0; while(the_repeater_field('...


0

Instead of is_tax(), which Determines whether the query is for an existing custom taxonomy archive page. you should use has_term(), Check if the current post has any of given terms. Like so, if ( has_term( 'booked', 'room_vacancy', $post_object ) ) { // Yay! }


1

the two filters don't have the same output. you can test that add_filter('acf/json_directory', function ($path) { return get_template_directory() . '/config/acf-json'; }); add_filter('acf/settings/save_json', function ($path) { return apply_filters("acf/json_directory", NULL); }); add_filter('acf/settings/load_json', function ($paths) { ...


0

Please check the ce_timestamp meta_key row in postmeta table. And make sure you have the valid dateformat as meta value.


0

Does changing this $cCounter; //attempt to count instances of this flexible content module To this $cCounter++; get you what you want?


1

What you're trying to do, can be achived by simply using the parse_request hook; no need for the custom rewrite rule and tag. So remove this (and you should flush the rewrite rules — just visit the permalink settings page): add_action( 'init', 'vacature_rewrite_rule' ); function vacature_rewrite_rule() { ... } Then use this modified function ...


0

I'd suggest editing your single template, instead of functions.php. So, in a child theme, edit single.php and whatever other templates your theme uses for the CPTs, at the location where it outputs the author's name. Where the author's name is being displayed, you can then also grab their user meta (gender and country) and output it. That way, you don't ...


0

It is possible to save ACF data in custom tables by using a separate paid plugin called ACF Custom Database Tables. However, if your goal is just to keep the database as light as possible, meevly.com's solution of creating your own custom metaboxes would be the lightest-weight option, versus adding two plugins just to track a few bits of data.


1

I was able to get to a similar solution // get the current taxonomy term $queried_object = get_queried_object(); $taxonomy = $queried_object->taxonomy; $term_id = $queried_object->term_id; $images = get_field('term_gallery', $taxonomy .'_' . $term_id); $size = 'full'; // (thumbnail, medium, large, full or custom size) $limit = 3; //how many ...


0

Unfortunately, you can't do that. In order to store your data in a separate database table, you should manually add custom meta boxes and save the data wherever you want. You can read more about it here: https://developer.wordpress.org/plugins/metadata/custom-meta-boxes/


1

As I pointed in the comments, if for example you're displaying 9 posts per page, which means there would be 3 gallery images shown per page, and you want page #1 to show images 1-3, page #2 to show images 4-6, and so on, then you would want to paginate the gallery images: // the number 3 below is the position where the image is to be added to $paged = max( ...


0

Editing the custom field itself would be the easiest way. In the field, under "Return Format," you can change it from Post Object to Post ID. That way, when you call for the data, you'll already have an array of just the IDs. If you're not able to change the field for some reason, you could alternatively code it something like <?php if (have_rows('...


1

No, not like that, hovering is something that happens in the browser, long after PHP has generated the page and shutdown. Fundamentally, you need to take a different more CSS based approach. Instead of providing static styles manually controlling the colours in PHP, you should instead only track wether it's dark or light, and specify a HTML class based on ...


2

You can create a shortcode and add it in any page you want. This code will register your custom shortcode: add_action( 'init', 'register_custom_shortcodes' ); function register_custom_shortcodes(){ add_shortcode( 'my-custom-shortcode', 'display_movies' ); } This code will be responsible for the content that will be displayed wherever you place the ...


3

It's because you have forgot to use $atts['post_id'] please find below code. function acf_featured_item_shortcode( $atts ) { // Attributes $atts = shortcode_atts( array( 'post_id' => '', ), $atts ); $post_id = $atts['post_id']; $image = get_field('featured_item', $post_id ); $size = 'medium'; // ...


0

Try this code <?php $image = get_field('team_members_page_image', 'option'); ?> <div class="post-hero-image archive-header" style="background-image: url('<?php echo $image ?>')">


0

Another way: Copy your shortcode in your WordPress text field: [contact-form-7 id="29"] And: <?php echo do_shortcode(get_field('form')); ?> Very small difference, a little bit easier.


0

You must create a different search form for your post type, so that search results can be displayed according to post type. You can add this to your search form <input type="hidden" name="post_type" value="meetup_groups"> Example : <form method="get" id="my-custom-searchform" action="<?php echo esc_url(home_url( '/' )); ?>"> &...


0

If you make a var_dump() on $link: var_dump('<pre>', $link); then you will see all array keys and you can choose the one you need.


0

in chrome/firefox Right click on the text area in question and hit "Inspect Element" You'll now be able to see the code of your site Don't click anywhere else, just look at the highlighted code. Look for class="something possiblysomethingelse" Find the something in the "quotes", just one of them. The spaces separate them if there is more than one. That is ...


Top 50 recent answers are included