How to: Customizing page2cat markup via a template
-
Strangely, the page2cat author embedded all the markup that the plugin outputs directly in the plugin, and I can’t find a way to get into contact with him/her to share how to fix this, so here it is in the hopes other users can find it useful.
This is the basic code snippet that will load a template named
page2cat.php
and use it to create the output of thepage2cat_output()
function:if (get_query_template('page2cat') != '') { load_template(get_query_template('page2cat')); }
To add this to your copy of the plugin, update one of the switch cases in the page2cat_output function in the page2cat.php plugin file. For instance, if you wanted to have this used by default you could replace the ‘getpost’ case in the function (starts line 749) with this:
case 'getpost': ?> <div id="category-page-header"> <?php $post = $post_temp; $post = get_post($pageid); setup_postdata($post); if($post->post_title!=""){ if (get_query_template('page2cat') != '') { load_template(get_query_template('page2cat')); } else { ?> <div id="p2c-header"> <h1><?php echo $post->post_title; ?></h1> <?php the_content(); ?> </div> <div class="category-page-cleaner"></div> <?php } echo '</div>'; $post = $post_temp; } break;
An example template that would work would be a page in your theme called
page2cat.php
with the following contents:<div id="p2c-header"> <h1><?php the_title(); ?></h1> <?php the_content(); ?> </div>
Hopefully this helps others; I’d love to see all of the markup in the plugin removed and replaced with optional templates, but I can’t find any good way to contact the developer.
- The topic ‘How to: Customizing page2cat markup via a template’ is closed to new replies.