Set page template for all pages?

EDIT As noted in the comments on your question, the best approach would just be to edit your page.php file. If you want ALL of your pages to have the same page template, and not have to do anything extra to set it that way, it’s quite obvious why this is a good idea. 🙂 … Read more

Page Template as Custom Post Type Archive

Since WordPress version 4.4 the hook ‘theme_page_templates’ allows to set arbitrary page templates. It means that it’s possible to show arbitrary values in the “Page Template” menu of the page edit screen, and when selected, the value will be stored in the page template meta for the page. This means that you can “automagically” create … Read more

What are the differences between custom post type and custom page templates?

Taxonomies are categorizations of data. Tags are a taxonomy. Categories are another taxonomy. If you are building a movie website and want to show which actors starred in which movie, “Movies” would be a custom taxonomy. Custom Post Types are really just custom data items. They’re stored just like posts and pages, but aren’t considered … Read more

Add custom template page programmatically

The article linked is on the right track, but i’ll make it more simple for you.. 😉 add_filter( ‘page_template’, ‘catch_plugin_template’ ); function catch_plugin_template( $template ) { if( ‘tp-file.php’ == basename( $template ) ) $template = WP_PLUGIN_DIR . ‘/yourpluginname/tp-file.php’; return $template; } The filter basically looks to see if your special page template is set for … Read more

Passing parameters to a custom page template using clean urls

add_rewrite_rule() allows you to turn the pretty url into variables. numbers: (\d*) section: /rid/ or /pageid/ slug: ([a-zA-Z0-9-]+ Here is a class to register the rewrite and handle the request if a match has been found. <?php if ( ! class_exists( ‘CPTURLRewrite’ ) ): class CPTURLRewrite { const ENDPOINT_QUERY_NAME = ‘pageid’; const ENDPOINT_QUERY_PARAM = ‘__pageid’; … Read more

How to add a .php file to WordPress

What you can do is this: Put up.php in your active theme’s folder, and put this line at the top of your up.php file: <?php /* Template Name: Up */ ?> Create a page called Up in your WordPress Dashboard, then on the right side of the edit page screen, set the Template to ‘Up’. … Read more

How to retrieve $_GET variables from rewritten URLs?

To be added on init: To register your custom variable (‘id’ in the question) add_rewrite_tag(‘%mycustomvar%’,'([^&]+)’); To create a re-write rule: add_rewrite_rule(‘^product/([0-9]{1,})/?’,’index.php?p=4&mycustomvar=$matches[1]’,’top’) 4 is the id of the ‘product’ page. You will need to flush rewrite rules once after adding these (go to Permalink settings page) You can get the value of mycustomvar: get_query_var( ‘mycustomvar’ ). … Read more

Do I need to use The Loop on pages?

According to the Theme Guide, full loops should be used, even on single templates. Full loops must be used in all templates. Just calling the_post() in a template like single.php or page.php is not enough. So yes, it’s a best practice to use full loops.