Creating subpages for each custom post type

Yes, setting the hierarchical option to true when you register the custom post type will mean each of your “shop pages” can have child “shop pages.” So you could have example.com/shop/shop-name/ example.com/shop/shop-name/hours/ example.com/shop/shop-name/contact/ etc. I believe ACF has a simple toggle to enable the hierarchical option. If you were registering it in code, you would … Read more

Meta query with ACF relationship field

Based on https://stackoverflow.com/questions/42011047/wordpress-query-by-acf-relationship-field, I was able to fix this by changing the ‘compare’ => ‘IN’ to ‘compare’ => ‘LIKE’. So the resultant code looks like this: $new_query_args = [ ‘meta_query’ => [ [ ‘key’ => ‘af_author’, ‘value’ => get_the_ID(), ‘compare’ => ‘LIKE’, ] ] ]; $query_args = array_merge( $query_args, $new_query_args ); I’m not exactly sure … Read more

Custom fields in the billing address section woocommerce

I have run into these issues before myself. I am not entirely sure it’s possible to get adjust the billing address box directly unless you adjust the actual email template for the emails. Specifically, if you have access to the file structure, look in the “/wp-content/plugins/woocommerce/templates/emails” folder of the WooCommerce Plugin. They are made to … Read more

Why the value of the selector doesnt remain visible in the custom field after I edit the post?

There’s nothing in your code that would allow this to happen. In your HTML you need to add a selected attribute to the <option> element representing the current value. WordPress includes a helper function, selected() which can help with this: function camere_meta_box_render( $post ){ $number = get_post_meta( $post->ID, “function_camere”, true ); echo ‘<div><select name=”function_camere”>’; for( … Read more

Sort wp_query of two post types using meta datefield for one and date for the other – possible?

Try this WP_Query arguments: $args = array( ‘post__in’ => $all_ids, ‘meta_query’ => array( ‘relation’ => ‘OR’, array( ‘key’ => ‘_event_date’, ‘compare’ => ‘EXISTS’, ), array( ‘key’ => ‘_event_date’, ‘compare’ => ‘NOT EXISTS’, ‘value’ => ‘dummy_value’ // This is just to ensure this condition gets evaluated. ) ), ‘orderby’ => array( ‘meta_value_num’ => ‘DESC’, ‘date’ => … Read more

Can’t expose custom field to REST API

I think the problem here is how you register the rest routes and how you return data for the single project endpoint. When you register the route and the callback like this. function single_project($data) { $post_ID = $data[‘id’]; return get_post($post_ID); } add_action(‘rest_api_init’, function () { register_rest_route( ‘project/v1’, ‘post/(?P<id>\d+)’, array( ‘methods’ => ‘GET’, ‘callback’ => ‘single_project’, … Read more

Can I count every article following extracted meta value?

Use array_count_values() (untested): <?php $posts = get_posts( array( ‘numberposts’ => -1, ‘category_name’ => ‘bird’, ‘order’ => ‘ASC’, ) ); if ( $posts ) { foreach( $posts as $post ) { $species[] = get_post_meta( $post->ID, ‘species1’, true ); $species[] = get_post_meta( $post->ID, ‘species2’, true ); } } $species = array_filter( $species ); $counts = array_count_values( $species … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)