Atahualpa Post Navigation

Altahualpa ‘next’ and ‘previous’ post navigation entries are global across all site postings.  When we are looking at postings by category we would like to our ‘next’ and ‘previous’ navigation links to show only postings within the category.

Fortunately, the WordPress functions next_post_link and previous_post_link provide an optional parameter to restrict links to categories.

Note: This functionality is now configurable in Atahualpa version 3.6.4


functions/bfa_next_previous_links.php

Modify the identified lines in function bfa_next_previous_post_links to be as shown:

function bfa_next_previous_post_links($location = "Top") {

global $bfa_ata;

	if ( is_single() AND strpos($bfa_ata['location_single_next_prev'],$location) !== FALSE AND

    // don't display on WP Email pages
    intval(get_query_var('email')) != 1 )  {

		echo '<div class="navigation-'.strtolower($location).'">
		<div class="older' . ($bfa_ata['home_single_next_prev'] != '' ?
        '-home' : '') . '">';

		$bfa_ata['next_prev_orientation'] == 'Older Left, Newer Right' ?
		previous_post_link('« %link', '%title', TRUE) :
		next_post_link('%link »', '%title', TRUE);

		echo '  </div>' . ($bfa_ata['home_single_next_prev'] != '' ?
        '<div class="home"><a href="' . $bfa_ata['get_option_home'] . '/">' .
        $bfa_ata['home_single_next_prev'] . '</a></div>' : '') .
		'<div class="newer' . ($bfa_ata['home_single_next_prev'] != '' ?
        '-home' : '') . '">  ';

		$bfa_ata['next_prev_orientation'] == 'Older Left, Newer Right' ?
		next_post_link('%link »', '%title', TRUE) :
		previous_post_link('« %link', '%title', TRUE);

		echo '</div><div class="clearboth"></div></div>';

	}
}

Atahualpa Custom Excerpts

There is a problem with Atahualpa custom excerpts not being processed correctly in category lists or other places where the post excerpt is displayed.  Note, this problem exists in Atahualpa version 3.4.

If you have this problem you will see ellipsis […] and word truncation when you have specified custom excerpts.  When a custom excerpt is provided on the post then the excerpt should be displayed in its entirety, without truncation.


functions.php

Add the identified line to function bfa_wp_trim_excerpt($text) as shown:

// Custom Excerpts
function bfa_wp_trim_excerpt($text) { // Fakes an excerpt if needed

	global $bfa_ata;

	if ( '' == $text ) {
		$text = get_the_content('');
		$text = apply_filters('the_content', $text);
		$text = str_replace(']]>', ']]>', $text);
		$text = strip_tags($text, $bfa_ata['dont_strip_excerpts']);
		$excerpt_length = $bfa_ata['excerpt_length'];
		$words = explode(' ', $text, $excerpt_length + 1);
	} else {
		$words = explode(' ', $text);
		$excerpt_length = count($words);  		// bug fix
	}

	if (count($words) > $excerpt_length) {
		array_pop($words);
		$custom_read_more = str_replace('%permalink%', get_permalink(), $bfa_ata['custom_read_more']);
		$custom_read_more = str_replace('%title%', the_title('','',FALSE), $custom_read_more);
		array_push($words, $custom_read_more);
		$text = implode(' ', $words);
	}

	return $text;
}

Show Atahualpa Comment

WordPress themes, including Atahualpa, typically show only a text link in the post footer that the user must click to enter a comment.  This does not encourage immediate user comment entry after viewing the post.

The comment entry screen can be displayed after a post if the the WordPress comments-template is invoked in the Loop.  The comments-template file references a PHP variable $withcomments which if true will cause the comment form to be displayed.


index.php

Replace the Atahualpa index.php with the following:

<?php 	/* get all options: */
include (TEMPLATEPATH . '/functions/bfa_get_options.php');
get_header(); ?>

<?php $withcomments = 1 ;  /* Required for the comment entry screen */ ?>

<?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 /* Show the comment entry screen on blog posts */
		if (is_home()) comments_template(); ?>

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


The comment form is shown for full posts and for excerpts on the home page. If the comment form should not show when posts are excerpts then the function bfa_post_bodycopy() in bfa_post_parts.php must be modified.

bfa_post_parts.php

function bfa_post_bodycopy($before = '<div class="post-bodycopy clearfix">', $after = '</div>') {

	global $bfa_ata, $post, $withcomments;

	echo $before;
	if ( (is_home() AND $bfa_ata['excerpts_home'] == "Full Posts") OR
	(is_category() AND $bfa_ata['excerpts_category'] == "Full Posts") OR
	(is_date() AND $bfa_ata['excerpts_archive'] == "Full Posts") OR
	(is_tag() AND $bfa_ata['excerpts_tag'] == "Full Posts") OR
	(is_search() AND $bfa_ata['excerpts_search'] == "Full Posts") OR
	(is_author() AND $bfa_ata['excerpts_author'] == "Full Posts") OR
	is_single() OR is_page() OR
	(is_home() AND !is_paged() AND $bfa_ata['postcount'] <= $bfa_ata['full_posts_homepage']) ) {
		$withcomments = 1 ;
		$bfa_ata_more_tag_final = str_replace("%post-title%", the_title('', '', false), $bfa_ata['more_tag']);
		the_content($bfa_ata_more_tag_final);
	} else {
		$withcomments = 0 ;
		the_excerpt();
	}
	echo $after;
}


As of the time of this post, a typing error in the function bfa_post_headline() in bfa_post_parts.php should be corrected.  This error will lead to incorrect post title display.

function bfa_post_headline($before = '<div class="post-headline">', $after = '</div>') {

	global $bfa_ata, $post;

	if ( is_single() OR is_page() ) {
		$bfa_ata_body_title = get_post_meta($post->ID, 'bfa_ata_body_title', true);
		$bfa_ata_display_body_title = get_post_meta($post->ID, 'bfa_ata_display_body_title', true);
	} else {
		$bfa_ata_body_title_multi = get_post_meta($post->ID, 'bfa_ata_body_title_multi', true);
	}

	if ( (!is_single() AND !is_page()) OR $bfa_ata_display_body_title == '' ) {

		echo $before; ?>
		<h<?php echo $bfa_ata['h_posttitle']; ?>><?php 

		if( !is_single() AND !is_page() ) { ?>

			<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php
		} 

		if ( (is_single() OR is_page()) AND $bfa_ata_body_title != "" ) {
			echo htmlentities($bfa_ata_body_title,ENT_QUOTES,'UTF-8');
		} else {
			if ( $bfa_ata_body_title_multi != '' ) echo htmlentities($bfa_ata_body_title_multi,ENT_QUOTES,'UTF-8');
			else the_title();
		}

		if ( !is_single() AND !is_page() ) { ?></a><?php } ?></h<?php echo $bfa_ata['h_posttitle']; ?>>
		<?php echo $after;
	}
}