Template files
-
I’m trying to accomplish something that is way above my head and involves php and the database. Chances are I don’t have the knowledge to do it, but I’m trying.
The simplest thing is to create a custom page template so I can insert php code into a page. I’ve tried several ways, but I can’t seem to place the php in the correct location to actually display withing the content area. I can get it above. I can get it below.
<?php
/**
* The Template for displaying all single pages.
*/
get_header(); ?>
<?php
/* Run the loop to output the pages.
* If you want to overload this in a child theme then include a file
* called loop-page.php and that will be used instead.
*/
the_post();
get_template_part( 'loop', 'page' );
?>
<?php get_footer(); ?>Mod
Quote:The simplest thing is to create a custom page template so I can insert php code into a pageThis is only an assumption. There may be easier ways.
If you want to insert PHP on every page or every post, you can use one Graphene’s many built-in action hook widget areas:
http://blog.kjodle.net/2011/11/04/graphene-action-hook-widgets-an-easy-way-to-modify-your-blog/
If you want to insert it only in a single page or post or only some of them, try this plugin:
Mod
Or any of these:
Kenneth,
Thanks for the info.
I was hoping to create a template so that I could reuse and/or change the same code on multiple pages, but I can’t seem to figure out how to create my own template. Everything I could find on Google is different from Graphene – there is no mention of get_template, which is what prompted my question.
Could you explain what the ‘loop’ and ‘page’ parts of get_template do? I’m guessing that loop pulls the WP loop and page pulls the content.
ronangelo: There is no get_content in any of the templates.
In the end I imagine it will be simpler to just use the insert php plugin, but it just seems unnecessary.
Viewing 6 posts - 1 through 6 (of 6 total)
- You must be logged in to reply to this topic.
