Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Atahualpa 3 Wordpress theme (http://forum.bytesforall.com/forumdisplay.php?f=2)
-   -   Custom Post Templates Revisited (http://forum.bytesforall.com/showthread.php?t=5611)

waded1 Jan 30, 2010 03:06 PM

Custom Post Templates Revisited
 
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.

Douglas Apr 24, 2010 06:07 AM

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?

paulae Apr 24, 2010 07:27 AM

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(); ?>


paulae Apr 24, 2010 08:34 AM

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?

juggledad Apr 24, 2010 02:37 PM

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 }; ?>


paulae Apr 24, 2010 03:34 PM

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?

juggledad Apr 24, 2010 08:53 PM

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.

Douglas Apr 25, 2010 06:45 AM

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?

paulae Apr 25, 2010 07:39 AM

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.

Douglas May 1, 2010 06:12 PM

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.

Hody Apr 7, 2012 09:35 AM

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. :o

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,
));



lmilesw Apr 7, 2012 10:43 AM

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.

Hody Apr 7, 2012 11:15 AM

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.


All times are GMT -6. The time now is 02:50 PM.

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