ACF | WooCommerce | Theme Development | How to include a /template-part/ that makes use of ACF’s on a custom WooCommerce homepage?

You cannot include template files via URL, which is what get_template_directory_uri() returns. You need to use the server file path, which you get get with get_theme_file_path(): $heroslider = get_theme_file_path( ‘template-parts/hero-slider.php’ ); echo $heroslider; include_once( $heroslider ); However, if you’re including templates (rather than files with function/class definitions), you should use get_template_part() to get the correct … Read more

How to hook the pre_get_posts filter via ajax call

You can apply a custom filter on your WP_Query that is on your ajax callback function like this: $my_query = apply_filters(‘my_plugin_pre_get_posts’, (new WP_Query($args))); Now you can use your existing pre_get_posts function for ajax calls also, add_action(‘pre_get_posts’, ‘myplugin_filter_posts’); // For All WP_Query instances add_filter(‘my_plugin_pre_get_posts’, ‘myplugin_filter_posts’); // For ajax function myplugin_filter_posts($query) { if (defined(‘DOING_AJAX’) && DOING_AJAX) { … Read more

Change a div background color on Post ID

This may not solve the problem necessary because there may be other rules in your theme that have higher specificity and will overrule your selectors but You need to combine the selector together, like so: .postid-6238.inside-article { background-color: #393939; } That selector will choose for all elements that have BOTH the classes .postid-6238 and .inside-article … Read more