Using pre_get_posts for meta value of LIKE comparison on ACF repeater sub field

You need to add Wildcards to your meta_value. Change $query->set(‘meta_query’, array( array( ‘meta_key’ => ‘test_repeater_%_test_sub_field’, ‘meta_value’ => $search, ‘compare’ => ‘LIKE’, ), )); To $query->set(‘meta_query’, array( array( ‘meta_key’ => ‘test_repeater_%_test_sub_field’, ‘meta_value’ => ‘%’.$search.’%’, ‘compare’ => ‘LIKE’, ), ));

How I can check if get_theme_mod is in header or a template part

I tried if ( ! did_action( ‘get_header’ ) ) but doesn’t seem to work. Try again, but this way: add_filter( ‘theme_mod_understrap_container_type’, ‘override_container_type’ ); function override_container_type( $value ) { if ( did_action( ‘get_header’ ) && ! did_action( ‘get_footer’ ) ) { if ( get_field(‘container_type’) !== ‘inherit’ ){ return get_field(‘container_type’); } } // For header.php and footer.php … Read more

Insert Commas into ACF number field

You need to ‘hook’ your function to a valid hook. Your add_action call is not doing anything, because it is not a proper call to a hook.. See the docs https://developer.wordpress.org/reference/functions/add_action/ for add_action. Your function is the second parameter of the add_action hook. The first parameter is ‘where’ to hook into WordPress. If you want … Read more

Acf Pro repeater field returns null [closed]

I’ve just solved this issue thanks to the Avanced WordPress group in Facebook (https://www.facebook.com/groups/advancedwp/). It was actually a mistake I had made: I had a query before the custom fields and it had to be reset. This is the working snippet: <?php // WP_Query arguments $args = array ( ‘post_type’ => ‘post’, ‘posts_per_page’ => ‘4’, … Read more

Sorting custom admin column by value

Ah, the remedy was a simple one: function issue_column_orderby( $vars ) { if ( isset( $vars[‘orderby’] ) && ‘linked_issue_post’ == $vars[‘orderby’] ) { $vars = array_merge( $vars, array( ‘meta_key’ => ‘article_issue_n’, ‘orderby’ => ‘meta_value’ ) ); } return $vars; } add_filter( ‘request’, ‘issue_column_orderby’ ); I probably omitted something before…

How to change the page title from functions.php

If you refer to the post title you need to hook your function to the_title filter like explained in the codex. add_filter(‘the_title’, ‘my_custom_title’, 10, 2); If you refer to the HTML meta in your page then you need to hook your function to document_title_parts filter explained here. add_filter(‘document_title_parts’, ‘my_custom_title’, 10, 2); The two filters work … Read more