Support » Themes and Templates » Atahualpa – Adding Custom Page Template?

  • I would like to create a few customized page templates for my Atahualpa page, but am uncertain how to do this since this theme does not seem to have a basic page template or a single page template that I could copy as a basis.

    Essentially all I want to do is display the page contents, followed by a call to display the most recent five items from a specific category. Should I create a new theme to do this, or is there some better way? (Essentially I want a widget type call function for latest category themes to display within the page).

    Thanks for any help you can offer!

Viewing 2 replies - 1 through 2 (of 2 total)
  • With a little persistence and a lot of experimentation I think I’ve found a solution. The code below borrows all the settings for header, sidebars etc, and displays your page content followed by a search form, and then a listing of recent items from your selection of categories…
    There are just two variables you need to fill in – the name of your template, the number of posts to display, and the numbers of the categories from which the posts should be drawn.

    <?php
    /*
    Template Name: PUT NAME OF YOUR PAGE TEMPLATE HERE
    */
    ?>
    <?php
    global $options;
    foreach ($options as $value) {
    	if (get_option( $value['id'] ) === FALSE) {
    		$$value['id'] = $value['std'];
    	} else {
    		$$value['id'] = get_option( $value['id'] );
    	}
    	$short_func_name = str_replace("bfa_ata_", "", $value['id']);
    	$bfa_ata[$short_func_name] = $$value['id'];
    }
    if ( is_page() ) { global $wp_query; $current_page_id = $wp_query->get_queried_object_id(); }
    //figure out sidebars
    global $cols;
    global $left_col;
    global $right_col;
    $cols = 1;
    if ( is_page() ) {
    $current_page_id = $wp_query->get_queried_object_id();
    	if ($bfa_ata['left_col_pages_exclude'] != "") {
    	$pages_exlude_left = explode(",", str_replace(" ", "", $bfa_ata['left_col_pages_exclude']));
    		if ( $bfa_ata['leftcol_on']['page'] AND !in_array($current_page_id, $pages_exlude_left) ) {
    		$cols++; $left_col = "on"; }
    	} else {
    		if ( $bfa_ata['leftcol_on']['page'] ) {
    		$cols++; $left_col = "on"; }
    	}
    	if ($bfa_ata['right_col_pages_exclude'] != "") {
    	$pages_exlude_right = explode(",", str_replace(" ", "", $bfa_ata['right_col_pages_exclude']));
    		if ( $bfa_ata['rightcol_on']['page'] AND !in_array($current_page_id, $pages_exlude_right) ) {
    		$cols++; $right_col = "on"; }
    	} else {
    		if ( $bfa_ata['rightcol_on']['page'] ) {
    		$cols++; $right_col = "on"; }
    	}
    } elseif ( is_category() ) {
    $current_cat_id = get_query_var('cat');
    	if ($bfa_ata['left_col_cats_exclude'] != "") {
    	$cats_exlude_left = explode(",", str_replace(" ", "", $bfa_ata['left_col_cats_exclude']));
    		if ( $bfa_ata['leftcol_on']['category'] AND !in_array($current_cat_id, $cats_exlude_left) ) {
    		$cols++; $left_col = "on"; }
    	} else {
    		if ( $bfa_ata['leftcol_on']['category'] ) {
    		$cols++; $left_col = "on"; }
    	}
    	if ($bfa_ata['right_col_cats_exclude'] != "") {
    	$cats_exlude_right = explode(",", str_replace(" ", "", $bfa_ata['right_col_cats_exclude']));
    		if ( $bfa_ata['rightcol_on']['category'] AND !in_array($current_cat_id, $cats_exlude_right) ) {
    		$cols++; $right_col = "on"; }
    	} else {
    		if ( $bfa_ata['rightcol_on']['category'] ) {
    		$cols++; $right_col = "on"; }
    	}
    } else {
    if ( (is_home() &amp;&amp; $bfa_ata['leftcol_on']['homepage']) OR
    ( function_exists('is_front_page') ? is_front_page() AND $bfa_ata['leftcol_on']['frontpage'] : '') OR
    ( is_single() &amp;&amp; $bfa_ata['leftcol_on']['single']) OR ( is_date() AND $bfa_ata['leftcol_on']['date']) OR
    ( is_tag() &amp;&amp; $bfa_ata['leftcol_on']['tag']) OR ( is_search() AND $bfa_ata['leftcol_on']['search']) OR
    ( is_author() &amp;&amp; $bfa_ata['leftcol_on']['author']) OR ( is_404() AND $bfa_ata['leftcol_on']['404']) OR
    ( is_attachment() &amp;&amp; $bfa_ata['leftcol_on']['attachment']) ) {
    	$cols++; $left_col = "on";
    	}
    if ( (is_home() &amp;&amp; $bfa_ata['rightcol_on']['homepage']) OR
    ( function_exists('is_front_page') ? is_front_page() AND $bfa_ata['rightcol_on']['frontpage'] : '') OR
    ( is_single() &amp;&amp; $bfa_ata['rightcol_on']['single']) OR ( is_date() AND $bfa_ata['rightcol_on']['date']) OR
    ( is_tag() &amp;&amp; $bfa_ata['rightcol_on']['tag']) OR ( is_search() AND $bfa_ata['rightcol_on']['search']) OR
    ( is_author() &amp;&amp; $bfa_ata['rightcol_on']['author']) OR ( is_404() AND $bfa_ata['rightcol_on']['404']) OR
    ( is_attachment() &amp;&amp; $bfa_ata['rightcol_on']['attachment']) ) {
    	$cols++; $right_col = "on";
    	}
    }
    ?>
    <?php get_header(); ?>
    
     <?php if (have_posts()) : while (have_posts()) : the_post();?>
     <div class="post">
      <h2 id="post-<?php the_ID(); ?>"><?php the_title();?></h2>
      <div class="entrytext">
       <?php the_content('<p class="serif">Read the rest of this page &raquo;</p>'); ?>
      </div>
     </div>
     <?php endwhile; endif; ?>
    
    <?php query_posts('showposts=5 &amp; cat=1,2,3,4,5'); ?>
    /*-- NOTE: TELL WORDPRESS HOW MANY POSTS TO SHOW, AND USE THE NUMBERS TO SPECIFY THE CATEORIES YOU WANT TO DISPLAY IN THE LINE ABOVE!*/
    <div style="color=#000099; font-size:25px; font-family: Georgia, Times, serif;
    	font-weight: bold; margin-top:20px">Latest News!</div><br />
    <?php if (have_posts()) : while (have_posts()) : the_post(); ?>
    <div style="color=#4557A0"><a href="<?php the_permalink() ?>"
          rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
    <?php the_title(); ?></a></div>
    <div style="margin-left:25px; margin-right:20px"><?php the_excerpt(); ?></div><br clear="all">
    <?php endwhile; ?>
    <?php endif; ?>
    
    <?php get_footer(); ?>

    Nevermind – question answered.

    Cheers,
    Brian

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Atahualpa – Adding Custom Page Template?’ is closed to new replies.