"Read more" Excerpt issue on Custom "Page" template to display Category post
-
I have asked this on another forum but perhaps here I can explain my issue more clearly here.
The platform: I have created a Custom “Page” template in my Child Theme. The purpose of this page is to display “Category” posts.
The Problem: the_excerpt – The “Read more” permalink is not directing away from the page to the intended post. It’s linked to the custom page the category posts are populating (same page).
My edits: The custom page template and the content.php file I have been modifying are locating in my child theme. My functions code is residing in the parent theme.
Custom page: `<?php
/*
Template Name: Category Food
*/
?>
<?php get_header(); ?>
<div id=”main” class=”row-fluid”>
<div id=”main-left” class=”span8″>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( ‘content’, ‘page’ ); ?><?php
$catPost = get_posts(‘cat=225&posts_per_page=3’);
foreach ($catPost as $post) : setup_postdata($post);
?><?php get_template_part(‘content’); ?>
<?php endforeach;?>
<?php comments_template( ”, true ); ?>
<?php endwhile; // end of the loop. ?><?php get_sidebar(); ?>
<div class=”clearfix”></div><?php get_footer(); ?>`
Content.php:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <h2 class="entry-title"> <span class="the_title"><a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'newszine' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"><?php the_title(); ?></a></span> <?php if( is_single() ){ return null; }else{ get_format( get_the_id() ); } ?> </h2> <?php do_action('after_post_title'); ?> <a href="<?php the_permalink(); ?>" title="<?php echo esc_attr( sprintf( __( 'Permalink to %s', 'newszine' ), the_title_attribute( 'echo=0' ) ) ); ?>" rel="bookmark"> <?php if( is_single() ){ if ( '1' == nz_option('nz_show_single_post_thumbnail') ) { the_post_thumbnail('post-single'); } }else if( is_home() ){ the_post_thumbnail('post-archive'); }else{ the_post_thumbnail('post-archive'); } ?> </a> <div class="entry-content"> <?php if ( is_category() || is_archive() || is_search() || is_home() ) { the_excerpt(); } else { the_excerpt(); } ?> </div> </article>The Function:
function themprefix_excerpt_read_more_link($output) { global $post; return $output . ' <a href="' . get_permalink($post->ID) . '" class="more-link" title="Read More">Read More >></a>'; } add_filter( 'the_excerpt', 'themprefix_excerpt_read_more_link' );note: permalinks work fine on the “category” post page, just not on the “page” template I created.
I’m not super savvy on this stuff. This permalink issue is the only thing holding me back from moving on to other things. I’m really hoping someone can help me out.
-
We provide support only for blogs being hosted WordPress.COM and not for WordPress.ORG software installs. You are posting to the wrong support forum.
WordPress.com and WordPress.org are completely separate and different http://support.wordpress.com/com-vs-org/
If you don’t have a username account at WordPress.ORG click http://wordpress.org/support/ and register one on the top right hand corner of the page that opens, so you can post to the support forums there and receive advice from WordPress.ORG bloggers.
- The topic ‘"Read more" Excerpt issue on Custom "Page" template to display Category post’ is closed to new replies.