How to create Page templates for showing Blog posts in different layouts?

I wouldn’t use custom page templates merely for changing the layout of the blog posts index. Using page templates for the blog posts index bypasses the core handling for display of the blog posts index (which per the template hierarchy uses either home.php or index.php to render). Edit I never…said that I want to change … Read more

How to get main menu only with wp_nav_menu

You can use the depth parameter like this: wp_nav_menu( array( ‘menu’ => ‘header-uk’, ‘menu_id’ => ‘nav’, ‘menu_class’ => ‘sitemap’, ‘fallback_cb’ => false, ‘depth’ => 1, ) ); Or if what you want to do is grab all items to create your own loop/output you can do that as well. Example: if ( ( $locations = … Read more

How to get current page nearest parent id?

try this. global $post; // if outside the loop $page_object = get_queried_object(); $page_id = get_queried_object_id(); // Get current page id $args = array( ‘sort_order’ => ‘ASC’, ‘sort_column’ => ‘post_title’, ‘hierarchical’ => 1, ‘exclude’ => ”, ‘include’ => $page_id, ‘meta_key’ => ”, ‘meta_value’ => ”, ‘authors’ => ”, ‘child_of’ => 0, ‘parent’ => -1, ‘exclude_tree’ => … Read more

Unlimited Page Sitemap Link

You are most probably exceeding the maximum execution time when trying to retrieve 7000 posts/products, or specifically more than 2000 posts/products. To be quite honest with you, 7000 posts/products (or even just a list of posts/products) all packed in one single page is not only going to drive you crazy, but anyone visiting your site. … Read more

Max Posts and Memory Limit

For me, this was happening b/c of post meta cache issues. This article suggested code which solved my issue – and apparently many other’s as well. https://junaid.dev/wordpress-admin-fix-fatal-error-allowed-memory-size-error/?unapproved=369&moderation-hash=bd9064ea40d413150d8a42599c13f4f5#comment-369 Here is the code he provides: function jb_pre_get_posts( WP_Query $wp_query ) { if ( in_array( $wp_query->get( ‘post_type’ ), array( ‘my_post_type_1’, ‘my_post_type_2’ ) ) ) { $wp_query->set( ‘update_post_meta_cache’, false … Read more

Custom wp_query – I’m getting ‘all’ post, not the specific post in the query

You should use tax_query for that. See official documentation here. Try this: $indicaArgs = array( ‘post_type’ => ‘product’, ‘productType’ => ‘Indica’, ‘locationCity’ => ‘Los Angeles’, ‘posts_per_page’ => -1, ‘post_status’ => ‘publish’, ‘tax_query’ => array( ‘relation’ => ‘AND’, array( ‘taxonomy’ => ‘productType’, ‘field’ => ‘slug’, ‘terms’ => ‘indica’, // here should be slug ), array( ‘taxonomy’ … Read more

Issue with data array format

Your code looks good though. But Try the following approach – $current_date = $_POST[‘current_date’]; $current_date = date( ‘Y-m-d’, strtotime($current_date) ); $post_id = (int) $_POST[‘post_id’]; $query = $wpdb->prepare( “SELECT start_date FROM {$wpdb->prefix}booking_history WHERE start_date=%s AND post_id=%d”, $current_date, $post_id ); /* get_col used to retrieve column records */ $results = $wpdb->get_col( $query ); echo ‘<pre>’; print_r( $results … Read more