Using Post Templates question
-
Hello, I’ve been thinking more and more about what I will do if I were to have to make design changes to my site. In the end it will have something like 400+ product type posts, and I might choose to add say a “details” section to the post later on, or shuffle some things around. The header, footer, and sidebars are easy to change of course.
Problem is what’s inbetween them, I use the HTML editor a lot and rarely use the visual WYSIWYG editor. So I have a layout with all the divs and what not set in place. But I copy and paste each design in its entirety into each post. And this will be a problem for scalability in the future.
So today I’ve been reading more about custom fields and their versatility. I just want to make sure I understand it correctly and whether or not you have some tricks to offer.
From my understanding with this loop <div id=”post-<?php the_ID(); ?>” <?php post_class(); ?>> you’re able to dynamically insert css based off a variable like a certain post class or even author. That might be useful in the future but not what I’m looking for.
I think what I’m looking for is being able to use post templates much like page templates and creating custom fields based off those templates to change content of each post.
So instead of having to copy this code into every post:
<div id="section1"> <p>blah blah blah </p> <div class="cool_box_price_other"> <div class="cool_price_green">$29.00</div> </div>I would create a post template like this:
<div id="section1> <p>echo get_post_meta($postid, 'review-content', true);</p> <div class="cool_box_price_other"> <div class="cool_price_green"> echo get_post_meta($postid, 'price', true); </div> </div>Something like that, and fill out each posts contents using custom fields that are associated with those custom posts… Is that generally how you developers create flexible wordpress sites?
ETA: Is is also possible to create post templates for excerpts?
The topic ‘Using Post Templates question’ is closed to new replies.