Wordpress Themes - WP Forum at BFA
Click Here To DONATE! Support the theme development, get more attention and additional benefits based on your donation level. Your forum name will be highlighted.

Wordpress Themes - WP Forum at BFA » WordPress Themes » Atahualpa 3 Wordpress theme »

Custom Post Templates Revisited


Build custom WP THEMES, without
coding.
Click here for THEMEFRAME

From the author of Atahualpa, the #1 most
downloaded (700,000+) theme @ wordpress.org
  #1  
Old Jan 30, 2010, 04:06 PM
waded1
 
5 posts · Nov 2009
Washington, USA
I have read through may threads on how to create Custom Post Templates while using the Atahualpa Theme. I am about 95% there. Here is a little background:

I am using a copy of index.php, renamed it to post-template.php. I added at the begining of the file.
Code:
<?php  /* creates a Post Template */
/*
Template Name Posts: Post-Template
*/
?>

I made all of the changes I wanted. I added them below:
Code:
<?php /* This is the actual Wordpress LOOP. 

		The output can be edited at Atahualpa Theme Options -> Style & edit the Center column */

		bfa_center_content($bfa_ata['content_inside_loop']); ?>
I am using the Custom Post Template Plugin so I can choose the custom post template within the post.

All of this works. The issue I am running into is when I use this custom post template, the information is added below the Information bar (bar that contains the Date, Category, Edit Post). I have tried moving my content to different areas within my post-template.php file. With no luck.

If it helps, here is a copy of my post-template.php

Code:
<?php  /* creates a Post Template */
/*
Template Name Posts: Custom-Post
*/
?>



<?php 	/* get all options: */

include (TEMPLATEPATH . '/functions/bfa_get_options.php');

get_header(); ?>



<?php /* If there are any posts: */

if (have_posts()) : $bfa_ata['postcount'] == 0; /* Postcount needed for option "XX first posts full posts, rest excerpts" */ ?>



	<?php /* This outputs the next/previous post or page navigation. 

	This can be edited at Atahualpa Theme Options -> Style & edit the Center column */

	bfa_center_content($bfa_ata['content_above_loop']); ?>



	<?php /* The LOOP starts here. Do this for all posts: */

	while (have_posts()) : the_post(); $bfa_ata['postcount']++; ?>

	

		<?php /* Add Odd or Even post class so post containers can get alternating CSS style (optional) */

		$odd_or_even = (($bfa_ata['postcount'] % 2) ? 'odd-post' : 'even-post' ); ?> 



		<?php /* This is the actual Wordpress LOOP. 

		The output can be edited at Atahualpa Theme Options -> Style & edit the Center column */

		bfa_center_content($bfa_ata['content_inside_loop']); ?>



<?php echo c2c_get_post_custom(559,"post-top"); ?>

<table align="left" style="width: 800px">
<tbody>
<tr style="height: 25px;">
<td style="text-align: center; height: 300px;" colspan="6" align="center" valign="top"><?php echo do_shortcode('[starratingmulti id=4 tpl=12]'); ?>

<strong>Write your own review of <?php echo c2c_get_custom(name); ?> at the bottom of this page.</strong></td>
<td style="text-align: right;" colspan="3" align="right"><?php echo c2c_get_post_custom(559,"ad-square"); ?></td>
</tr>
</tbody>
</table>

<?php echo c2c_get_post_custom(559,"post-middle"); ?>

<h1><?php echo c2c_get_custom(name); ?> Details</h1>
<?php echo c2c_get_custom(details); ?>

<h3>Recreation near <?php echo c2c_get_custom(name); ?></h3>
<?php echo c2c_get_custom(recreation); ?>

<h3>Directions to <?php echo c2c_get_custom(name); ?></h3>
<?php echo c2c_get_custom(directions); ?>

<h3>Photo Gallery</h3>
<?php echo do_shortcode('[showtime]'); ?>

<h4>Additional Information</h4>
<?php echo c2c_get_post_custom(559,"ad-footer"); ?>
<?php echo c2c_get_post_custom(559,"post-bottom"); ?>

<h4>Write your own review of <?php echo c2c_get_custom(name); ?> below:</h4>


						

	<?php /* END of the LOOP */

	endwhile; ?>



	<?php /* This outputs the next/previous post or page navigation and the comment template.

	This can be edited at Atahualpa Theme Options -> Style & edit the Center column */

	bfa_center_content($bfa_ata['content_below_loop']); ?>



<?php /* END of: If there are any posts */

else : /* If there are no posts: */ ?>



<?php /* This outputs the "Not Found" content, if neither posts, pages nor attachments are available for the requested page.

This can be edited at Atahualpa Theme Options -> Style & edit the Center column */

bfa_center_content($bfa_ata['content_not_found']); ?>



<?php endif; /* END of: If there are no posts */ ?>



<?php bfa_center_content($bfa_ata['center_content_bottom']); ?>



<?php get_footer(); ?>
Thank you in advance for any assistance.
  #2  
Old Apr 24, 2010, 07:07 AM
Douglas
 
15 posts · Apr 2010
I'd love it if Paulae could respond to this question, as it relates to her previous answer (http://forum.bytesforall.com/showthread.php?t=6057).

I am trying to set up some custom post templates, too. But the Index.php file in version 3.4.6 doesn't seem to have as much content in the loop (compared to Paulae's example). The new version has a single block for "This is the actual WordPress loop" instead of the individually listed components "bfa kicker, headline, etc."

This may be waded1's problem -- that he/she can't find a way to insert custom code between the individual components of the page because they're not individually listed.

What are we missing?
  #3  
Old Apr 24, 2010, 08:27 AM
paulae's Avatar
paulae
 
1,332 posts · Feb 2009
Wordpress 3.4.1, Atahualpa 3.7.7
Ah. You know what? When I switched from Atahualapa 3.4.5 to 3.4.6, I just copied my custom post templates right into the folder and didn't change them at all. So right now, they are based on the old index.php, not the new one! They work just fine, but I'm glad you brought this to my attention. I've fixed one of them. I'm pasting it in, and you'll see the code I added in red. I want the custom part to show up at the end of the post, before the comments box.

Of course, you can do much the same thing by creating a new widget area and putting it where you want it in the center column theme options area.

I think if you want to put custom content in a more precise area, there might be a layout plugin for that.

Code:
<?php
/*
Single Post Template: my-newcareerdoctor-template
Description: This part is optional, but helpful for describing the Post Template
*/
?>
<?php 	/* get all options: */
include (TEMPLATEPATH . '/functions/bfa_get_options.php');
get_header(); ?>

<?php /* If there are any posts: */
if (have_posts()) : $bfa_ata['postcount'] == 0; /* Postcount needed for option "XX first posts full posts, rest excerpts" */ ?>

	<?php /* This outputs the next/previous post or page navigation. 
	This can be edited at Atahualpa Theme Options -> Style & edit the Center column */
	bfa_center_content($bfa_ata['content_above_loop']); ?>

	<?php /* The LOOP starts here. Do this for all posts: */
	while (have_posts()) : the_post(); $bfa_ata['postcount']++; ?>
	
		<?php /* Add Odd or Even post class so post containers can get alternating CSS style (optional) */
		$odd_or_even = (($bfa_ata['postcount'] % 2) ? 'odd-post' : 'even-post' ); ?> 

		<?php /* This is the actual Wordpress LOOP. 
		The output can be edited at Atahualpa Theme Options -> Style & edit the Center column */
		bfa_center_content($bfa_ata['content_inside_loop']); ?>
		<hr align=center>

<center><img src="http://www.larchmontgazette.com/wp27/wp-content/uploads/2009/12/plumezheader2.jpg"></center>
<p>Please <a href="http://larchmontgazette.com/careerdoctor/ask-the-career-doctor-a-question">click here</a> to ask the Career Doctor a question.</p>
						
	<?php /* END of the LOOP */
	endwhile; ?>

	<?php /* This outputs the next/previous post or page navigation and the comment template.
	This can be edited at Atahualpa Theme Options -> Style & edit the Center column */
	bfa_center_content($bfa_ata['content_below_loop']); ?>

<?php /* END of: If there are any posts */
else : /* If there are no posts: */ ?>

<?php /* This outputs the "Not Found" content, if neither posts, pages nor attachments are available for the requested page.
This can be edited at Atahualpa Theme Options -> Style & edit the Center column */
bfa_center_content($bfa_ata['content_not_found']); ?>

<?php endif; /* END of: If there are no posts */ ?>

<?php bfa_center_content($bfa_ata['center_content_bottom']); ?>

<?php get_footer(); ?>

Last edited by paulae; Apr 24, 2010 at 08:29 AM.
  #4  
Old Apr 24, 2010, 09:34 AM
paulae's Avatar
paulae
 
1,332 posts · Feb 2009
Wordpress 3.4.1, Atahualpa 3.7.7
I'm replying to my own post to see if Juggledad can jump in here.

What if, instead of making a custom post template, you could use a PHP statement in the ATO/Center Column insert area? What would the syntax be, to tell Wordpress to add some code only on posts in a certain category? This would make the Custom Posts Template plugin unnecessary, as well as the custom templates.

Let's say I'd like to add this to every Career Doctor (category 5) post, just before the comment area:
Code:
<hr align=center>

<center><img src="http://www.larchmontgazette.com/wp27/wp-content/uploads/2009/12/plumezheader2.jpg"></center>
<p>Please <a href="http://larchmontgazette.com/careerdoctor/ask-the-career-doctor-a-question">click here</a> to ask the Career Doctor a question.</p>
How would I use the PHP code to make that happen?
  #5  
Old Apr 24, 2010, 03:37 PM
juggledad's Avatar
juggledad
 
22,326 posts · Mar 2009
OSX 10.8.5 WP 3.8.x Atahualpa 3.7.x Safari 6.x Firefox 25 XP
try this
HTML Code:
<?php if (in_category('5')) { ?>
<hr align=center>
<center><img src="http://www.larchmontgazette.com/wp27/wp-content/uploads/2009/12/plumezheader2.jpg"></center>
<p>Please <a href="http://larchmontgazette.com/careerdoctor/ask-the-career-doctor-a-question">click here</a> to ask the Career Doctor a question.</p>
<?php }; ?>
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #6  
Old Apr 24, 2010, 04:34 PM
paulae's Avatar
paulae
 
1,332 posts · Feb 2009
Wordpress 3.4.1, Atahualpa 3.7.7
Beautiful! If I put that in the ATO/Center Column styling/below the loop, it's just where I need it. From a page-load point of view, do you think it's faster to do this, or to use the Post Templates plugin/special template combo?
  #7  
Old Apr 24, 2010, 09:53 PM
juggledad's Avatar
juggledad
 
22,326 posts · Mar 2009
OSX 10.8.5 WP 3.8.x Atahualpa 3.7.x Safari 6.x Firefox 25 XP
Depends on how you want to measure it. For absolute load time of the page, the template is probably faster. In terms on ongoing maintenance, putting it in the ato option will be less time consuming since you won't have to remember to do it during upgrades.
__________________
"Tell me and I forget, teach me and I may remember, involve me and I learn." - Benjamin Franklin
Juggledad | Forum Moderator/Support
  #8  
Old Apr 25, 2010, 07:45 AM
Douglas
 
15 posts · Apr 2010
Paulae,

Thanks so much for following up on this topic.

I was intending to create a highly customized template for a book reviews section (category) of the site. I was planning on creating and populating a number of custom fields for each review post, and I wanted to build a template to automatically concatenate and display the values of these fields. I would want most if not all of this customized content to appear at the beginning of the main body of the post, and then perhaps a second block at the end (like your example) that would feature information about the reviewer.

This seemed simpler to design when those individual components were called out in the index.php. Now that the index.php doesn't list those component blocks of the body, I'm not sure how to customize it. You mention that there might be a plugin for that, but surely there's got to be a way to do it more "directly".

Suggestions?
  #9  
Old Apr 25, 2010, 08:39 AM
paulae's Avatar
paulae
 
1,332 posts · Feb 2009
Wordpress 3.4.1, Atahualpa 3.7.7
Would the custom field values remain the same for each post in the category? If the info will be pretty static, why can't you just put it in a PHP statement as Juggledad showed us, in the Content Above the Loop area of the theme options/Center Column?

For the reviewer info, I believe there are some author bio plugins.

For layout, you could try this plugin: http://wordpress.org/extend/plugins/post-layout/

I tried it on one site and it caused conflicts, but I use 2 of Satollo's other plugins (Newsletter and Hypercache) successfully, so maybe this one has been improved.
  #10  
Old May 1, 2010, 07:12 PM
Douglas
 
15 posts · Apr 2010
Thanks for the ideas, Paulae and Juggledad. I was probably getting more complicated than I need to be initially. The site I'm working on might not ever take off, but I have been trying to work out some details at the start so that some higher level functions are possible if and when things scale up.
  #11  
Old Apr 7, 2012, 10:35 AM
Hody's Avatar
Hody
 
156 posts · Apr 2012
Don´t wont to hijack another thread - but seriously find it easier to search for threads with similiar problems than to open a new one each time - hope I am doing it right this time.

I have used a plugin already that allowed me to create meta custom fields, the plugin already has a function to limit the output to a selected category - and also an option to output the php code already - which I have attached below.

The question is now, where do I have to add this code in order to appear as a meta box in all my postings - because under the above mented ATO/center area options is a message: Since 3.6.5 custom PHP code isn't possible anymore in the Atahualpa Theme Options

PHP Code:
/**
 * Activate Add-ons
 * Here you can enter your activation codes to unlock Add-ons to use in your theme. 
 * Since all activation codes are multi-site licenses, you are allowed to include your key in premium themes. 
 * Use the commented out code to update the database with your activation code. 
 * You may place this code inside an IF statement that only runs on theme activation.
 */ 
// if(!get_option('acf_repeater_ac')) update_option('acf_repeater_ac', "xxxx-xxxx-xxxx-xxxx");
// if(!get_option('acf_options_ac')) update_option('acf_options_ac', "xxxx-xxxx-xxxx-xxxx");
// if(!get_option('acf_flexible_content_ac')) update_option('acf_flexible_content_ac', "xxxx-xxxx-xxxx-xxxx");


/**
 * Register field groups
 * The register_field_group function accepts 1 array which holds the relevant data to register a field group
 * You may edit the array as you see fit. However, this may result in errors if the array is not compatible with ACF
 * This code must run every time the functions.php file is read
 */
if(function_exists("register_field_group"))
{
register_field_group(array (
  
'id' => '4f80551e79455',
  
'title' => 'ReviewsMetaBox',
  
'fields' => 
  array (
    
=> 
    array (
      
'key' => 'field_4f7f4b357fe0d',
      
'label' => 'Cover',
      
'name' => 'cover1',
      
'type' => 'image',
      
'instructions' => 'Hier das Coverbild einfügen',
      
'required' => '1',
      
'save_format' => 'url',
      
'preview_size' => 'full',
      
'order_no' => '0',
    ),
    
=> 
    array (
      
'key' => 'field_4f7f4b3580dbb',
      
'label' => 'Spielname',
      
'name' => 'name1',
      
'type' => 'text',
      
'instructions' => 'Der Name des Games',
      
'required' => '1',
      
'default_value' => '',
      
'formatting' => 'html',
      
'order_no' => '1',
    ),
    
=> 
    array (
      
'key' => 'field_4f7f4b3581960',
      
'label' => 'Preis',
      
'name' => 'preis1',
      
'type' => 'text',
      
'instructions' => 'Der ca. Ladenpreis',
      
'required' => '1',
      
'default_value' => '',
      
'formatting' => 'html',
      
'order_no' => '2',
    ),
    
=> 
    array (
      
'key' => 'field_4f7f4b3582515',
      
'label' => 'Entwickler',
      
'name' => 'entwickler1',
      
'type' => 'text',
      
'instructions' => 'Der Entwickler des Spiels',
      
'required' => '1',
      
'default_value' => '',
      
'formatting' => 'html',
      
'order_no' => '3',
    ),
    
=> 
    array (
      
'key' => 'field_4f7f4b35830e1',
      
'label' => 'Publisher',
      
'name' => 'publisher1',
      
'type' => 'text',
      
'instructions' => 'Der Publisher (Vertrieb) des Spiels',
      
'required' => '1',
      
'default_value' => '',
      
'formatting' => 'html',
      
'order_no' => '4',
    ),
    
=> 
    array (
      
'key' => 'field_4f7f4b3583c9e',
      
'label' => 'USK',
      
'name' => 'usk1',
      
'type' => 'select',
      
'instructions' => 'Die USK Einstufung',
      
'required' => '1',
      
'choices' => 
      array (
        
=> '0',
        
=> '6',
        
12 => '12',
        
16 => '16',
        
18 => '18',
        
'' => '',
      ),
      
'default_value' => '',
      
'allow_null' => '0',
      
'multiple' => '0',
      
'order_no' => '5',
    ),
    
=> 
    array (
      
'key' => 'field_4f7f4b3584858',
      
'label' => 'USK Logo',
      
'name' => 'uskbild1',
      
'type' => 'image',
      
'instructions' => 'Das USK Bild',
      
'required' => '1',
      
'save_format' => 'id',
      
'preview_size' => 'full',
      
'order_no' => '6',
    ),
  ),
  
'location' => 
  array (
    
'rules' => 
    array (
      
=> 
      array (
        
'param' => 'post_category',
        
'operator' => '==',
        
'value' => '4',
        
'order_no' => '0',
      ),
    ),
    
'allorany' => 'all',
  ),
  
'options' => 
  array (
    
'position' => 'side',
    
'layout' => 'default',
    
'show_on_page' => 
    array (
      
=> 'custom_fields',
    ),
  ),
  
'menu_order' => 0,
));

__________________
...that I rock, doesn´t mean I am made of stone!
My Blog: Diary of a Fatman - Run Fatboy Run! - Tribe Online Magazine - Freiburg
  #12  
Old Apr 7, 2012, 11:43 AM
lmilesw's Avatar
lmilesw
 
10,110 posts · Jul 2009
Central New York State USA
The code for new widget areas is allowed in many spots so you could create a new widget area and then use a plugin that allows php.
__________________
~Larry (CNY Web Designs)
This site should be a membership site since it so full of good stuff.
Please consider donating which gives you access to even more good stuff.
  #13  
Old Apr 7, 2012, 12:15 PM
Hody's Avatar
Hody
 
156 posts · Apr 2012
I have tried the "POST LAYOUT" Plugin already without any success. In my other blog I use "WIDGET ON PAGES" - maybe that might help, but I would need everything to appear in a kind of table like shown here on the left side of the review.
__________________
...that I rock, doesn´t mean I am made of stone!
My Blog: Diary of a Fatman - Run Fatboy Run! - Tribe Online Magazine - Freiburg

Bookmarks

Tags
atahualpa, custom post template

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Disabling Link in Titles .. Revisited redacter Post-Kicker, -Byline & -Footer 7 Nov 8, 2010 07:10 PM
[SOLVED] post - custom field isa Forum How-To 0 Sep 17, 2009 03:44 PM
Category Page Revisited gungo Plugins & Atahualpa 12 Jul 28, 2009 01:36 PM
Custom post fields wwday3 Post-Kicker, -Byline & -Footer 8 Jul 28, 2009 12:39 PM


All times are GMT -6. The time now is 09:51 AM.


Powered by vBulletin® Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.