get post id from wp_insert_post for get_template_part

Declare $my_post_id as global in your code. Declare $my_post_id as global in the-post.php template. Your code: global $my_post_id; $my_post = array( ‘post_type’ => ‘theposttt’, ‘post_title’ => ‘test’, ‘post_content’ => ”, ‘post_status’ => ‘publish’, ‘post_author’ => 1 ); $my_post_id = wp_insert_post($my_post); if(is_wp_error($my_post_id)) $my_post_id = 0; Now, you can use $my_post_id in the-post.php template. Possible values: 0 … Read more

How to display different submenus?

It is ok to put other elements as child elements. I don’t see any problem with this. To add custom elements you have to add custom metabox to menu administration. WordPress will handle saving your custom elements automatically so you don’t need to worry about this. To display your custom elements you can create custom … Read more

WP_Query multiple post results

Your loop is wrong, you should not use to foreach inside the while, simply add the classic the_post () using the variable of your loop in this case $ loop for example <?php $args = array( ‘post_type’ => ‘product’, ‘stock’ => 1, ‘posts_per_page’ => 9, ‘product_cat’ => $pagename, ); $loop = new WP_Query( $args ); … Read more

Problem with custom loop and wp_list_pluck [closed]

Problem solved! You need to change this part of code before 3rd query… it will merge you previous queries and exclude posts from them: $first_grid_posts_ids = wp_list_pluck( $first_grid_query->posts, ‘ID’ ); $second_grid_posts_ids = wp_list_pluck( $second_grid_query->posts, ‘ID’ ); $allTheIDs = array_merge( $first_grid_posts_ids , $second_grid_posts_ids ); $third_grid_query = new WP_Query( array( ‘posts_per_page’=>4, ‘post_type’ => ‘post’, ‘cat’ => get_query_var(‘cat’), … Read more