Get Custom post with ID

You simply don’t need to specify a post_type when calling get_post(). The ID for any sort of post is unique among the whole DB-posts table. So if you’re calling a post with ID = 17 $id = 17; $post = get_post( $id ); then you’ll simply get this single post. Note, according the Codex, when … Read more

Multiple Loops Homepage?

You can use current_post within the loop to track where you are and split the loop into multiple parts: while ( have_posts() ) : the_post(); // only output content if it’s post 1 – 5 if( 5 > $wp_query->current_post ): the_title(); else : break; endif; endwhile; // do another query/loop $custom_loop = new WP_Query( $args … Read more

wc_get_template_part( ‘content’, ‘product’ ) | Where is this file located?

As mentioned in the comments, wc_get_template_part() tries to locate and load the requested template file. These template files could be ether in the /woocommerce/ sub-directory of a child-theme, or defined in another third party plugin (with the help of woocommerce_locate_template filter hook). If none of these exists, WC loads the default template file from /plugins/woocommerce/templates/ … Read more

$post>ID displays wrong post ID

If i understand correctly you are trying to display a list of child pages of a page in a widget, if so then first check if you are on a page using the conditional tag is_page() then you can use $wp_query->get_queried_object_id() like t31os has pointed out so your widget display function should look like this: … Read more

Child Pages Loop

I’m fairly certain the problem is that some template tags rely on the global $post variable. Using setup_postdata() as you are now, will not alter $post. If you replace all the instances of $pageChild with $post, everything should work. However, I would strongly recommend using the WP_Query class and setting up your post data with … Read more

Pagination not working on home page

I had faced the same problem. And finally, I solved the problem. Getting the current Pagination Number <?php $paged = (get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; ?> For getting the current pagination number on a static front page (Page template) you have to use the ‘page’ query variable. <?php $paged = (get_query_var(‘page’)) ? get_query_var(‘page’) : 1; … Read more