Tag Info

Hot answers tagged

3

You can approach this by first using a database query to count the number of pages that are already using the template: $query = "SELECT COUNT(*) as total FROM prefix_posts as p JOIN prefix_postmeta as m ON p.ID = m.post_id WHERE p.'post_type' = 'page' AND p.'post_status' = 'publish' AND m.'meta_key' = '_wp_page_template' AND ...


1

I tested the query and it does work so the only thing I can spot that is misleading but not right is directly after you while() statement you have the_post(). This doesn't work in secondary queries, it should look like: <?php if( $subpages->have_posts() ) : ?> <?php while( $subpages->have_posts() ) : $subpages->the_post(); ?> ...


1

Harman, don't use get_posts() when pagination is required. You may also accomplish this task using WP_Query. Refer to this answer explained beautifully by Chip Bennett at How to fix pagination for custom loops? <?php $user_fav = get_user_favorites($user_id); $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args ...


1

You will create a page template whose file name is custompage-template.php here I suppose put in in your plugin dir/views/ folder. Whenever the page whose title is Your Page Name is visited, the site will render your custom template add_filter( 'page_template', 'fw_reserve_page_template' ); function fw_reserve_page_template( $page_template ) { if ( ...



Only top voted, non community-wiki answers of a minimum length are eligible