Tag Info

New answers tagged

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 ( ...


0

My approach was also correct but the only problem was we were missing is that resetting the query before the post navigation links. Here is the updated answer. <?php $user_fav = get_user_favorites($user_id); $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $args = array( 'posts_per_page' => 4, ...


0

I have Found a way which I use regularly to add my own created PHP to a PHP PAGE or post through the use of Short Codes. Now Create a PHP page named example.php in your theme root directory. write something like: <?php echo "Hi! I am a PHP File in Wordpress template Folder!" ?> Now add the following code to your functions.php function ...


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 ...


0

I figured out a way to do this using the dashboard, not coding needed. BOOM! :) I was over thinking this. Step 1: Go to the page in the dashboard and edit the title to what you want. Update the page. Step 2: Goto Appearance>Menus and select the page with the coma in the name and click on the down arrow on the left, delete the coma (or whatever it is). ...


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(); ?> ...


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 ...



Top 50 recent answers are included