Create a blank test.php

I usually do this for just code (no HTML): add_action(‘template_redirect’, ‘test’); function test() { // code goes here die; } For dealing with HTML I prefer blank theme, set up for testing. If you want to test in context of existing theme create custom page template, add/remove elements according to your needs and assign to … Read more

Differnt page template for page 2 of blog feed

Not sure if you can use a complete different template but you can use different template parts using the global $page variable. Example: global $page; if ( $page == 2 ) { get_template_part( ‘page’, ‘two’ ); } else { get_template_part( ‘page’, ‘default’); } This would load the template file page-two.php or page-default.php depending on what … Read more

persist a variable set in header.php all the way down to footer.php

You’d have to declare it first above those includes and globalize it within header or footer before getting or setting the value. however- in the specific context you’re speaking of- getting a custom field value, it’s only retrieved from the database on the first call, then cached, so subsequent calls won’t hit the database again.

WordPress 3.3.1 single post template

For page templates, click on screen options in the top right corner and check the Page Attributes box. If your theme has no page templates to choose from then the template drop down will not be shown. Posts and other post types do not use or support page templates and never have. Only pages support … Read more

Why won’t pagination work?

probably coz you override the default query and forgot to take care of pagination 🙂 change the code this way: $page = isset(get_query_var(‘paged’)) ? get_query_var(‘paged’) : 1; $args = array( ‘numberposts’ => $numposts, ‘paged’ => $paged ); This should do the work

how can I add a “read more” tag directly in the template?

The code would probably be something like this: echo ‘<a href=”‘ . get_permalink() . “#more-{$post->ID}\” class=\”more-link\”>”.__( ‘Read more &gt;’, ‘your-theme’ ). ‘</a>’; Check out the source on how WordPress does it: http://core.trac.wordpress.org/browser/tags/3.3.1/wp-includes/post-template.php#L219 This has to be inside the loop to work and the $post global has to be visible in the current scope.

Archive template limiting to 4 entries?

This has nothing to do with the loop in the template file. Check Settings>>Reading>>”Blog pages show at most…” That setting is the default setting for Archives, too, as well as Search results, etc. Use WordPress › Custom Post Limits « WordPress Plugins to vary posts limits in categories, archives, etc.