• Christine357

    (@christine357)


    Hi everyone. I am using a ‘Page of Posts’ template found here and I am trying to figure out how to remove the tags from just this page (which is my home page). It is just showing an excerpt of the posts, making it very cluttered looking with the tags.

    I’ve already researched and found several other solutions that do not work for my issue such as:

    Yes – simply don’t use <?php the_tags();?> within the Loop in your template files

    and

    .tags {
    display: none;
    }

    both from here.

    I don’t have that php line in the Page of Posts template and the CSS solution would remove all tags.

    I know where I can edit how the entry-meta is displayed through functions.php but again, this change is done from entire site.

    Any assistance please?

Viewing 7 replies - 1 through 7 (of 7 total)
  • Michael

    (@alchymyth)

    the tags etc are called via the code <?php twentytwelve_entry_meta(); ?> in the content.php template of Twenty Twelve;
    to remove them just for the ‘page of posts’ you will need to edit a copy of that function twentytwelve_entry_meta() in functions.php of your child theme, probably based on a conditional statement using ‘is_page_template()’ – http://codex.wordpress.org/Function_Reference/is_page_template

    for example change this section:

    if ( $tag_list ) {
    		$utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	} elseif ( $categories_list ) {

    to:

    if ( $tag_list ) {
    		if( is_page_template( 'your_page_of_posts_template_file_name.php' ) ) { $utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); } else { $utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' ); }
    	} elseif ( $categories_list ) {

    unfortunately, there is no specific CSS to just target the tags.

    Thread Starter Christine357

    (@christine357)

    Thanks alchymyth for the information!

    Trouble is, for some reason it is not recognizing that the template is being used or whatever because the code in the else statement is being run.

    if ( $tag_list ) {
    		//$utility_text = __( 'This entry was posted in %1$s and tagged %2$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    		if(is_page_template('homeTemplate.php')){
    			$utility_text = __( '%3$s | by %4$s | in %1s' );
    		}
    		else{
    			$utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    		}
    	} elseif ( $categories_list ) {
    		$utility_text = __( 'This entry was posted in %1$s on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	} else {
    		$utility_text = __( 'This entry was posted on %3$s<span class="by-author"> by %4$s</span>.', 'twentytwelve' );
    	}

    I can %100 guarantee that ‘homeTemplate’ is the template file that is being used. Perhaps I did something wrong with the code? It seems fine to me, but I can’t imagine why it is not working. In the editor, underneath the name of my template it shows the filename, (homeTemplate.php). That is what I am using.

    Michael

    (@alchymyth)

    can you provide a live link to the page using that page template?

    be aware that if the page is set as ‘posts page’ under dashboard – settings – reading it will not use the page template, but simply index.php or home.php

    Thread Starter Christine357

    (@christine357)

    It is set as Front Page. Here is the code:

    <?php
    /**
     * Template Name: Page of Posts
     *
     * for a child theme of Twenty_Twelve
     */
    
    get_header( 'home' ); ?>
    
            <div id="primary" class="site-content">
                    <div id="content" role="main">
    
    	<div id="aboutHurkyWrap">
    		<div>Mission Statement</div>
    		<p>We seek success; not to step in the path of the established, but to leap away from the prevalent into a class of our own.  By developing a self-nurturing, ecosystem, we’ll harvest the finest natural ingredients to create our handcrafted brews and ciders.  More importantly, it is essential that we form a companionship within our community, help and donate to those in need, all while supporting the increasing health of our local environment. As we climb toward perfection, we'll make a point to share our product with all the great people around us.</p>
    	</div>
    
                    <?php
                            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                            $args= array(
                                    'category_name' => 'Uncategorized', // Change this category SLUG to suit your use; or see for query parameters http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
                                    'paged' => $paged,
    				'posts_per_page' => 3,
    				'post_type' => 'post',
    );
                            query_posts($args);
                            if( have_posts() ) : ?>
    
    <div id="blogWrapTitle"><a href="http://hurkybird.com/blog-2/">Blog</a></div>
    
                			<?php while ( have_posts() ) : the_post(); ?>
                   				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    						<!-- Adds the 140x140 thumbnail/featured image -->
            <div class="excerpt-thumb">
    	<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
                <?php the_post_thumbnail('excerpt-thumbnail', 'class=alignleft'); ?>
                </a>
            </div>
    						<div id="title_summary-wrap">
    						<header class="entry-header">
    							<h1 class="entry-title">
    								<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?>
    							</h1>
    
    							<?php twentytwelve_entry_meta(); ?>
    						</header><!-- .entry-header -->
    
    						<div class="entry-summary">
    							<?php the_excerpt(); ?>
    						</div><!-- .entry-summary -->
    						</div>
    
    						<footer class="entry-meta">
    							<!-- meta was here -->
    							<?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
    						</footer><!-- .entry-meta -->
    	</article><!-- #post -->
                    				<?php comments_template( '', true ); ?>
                					<?php endwhile; // end of the loop. ?>
    
                		<?php else : ?>
                			<article id="post-0" class="post no-results not-found">
                    			<header class="entry-header">
                        				<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentytwelve' ); ?></h1>
                    			</header>
                    			<div class="entry-content">
    <?php the_post_thumbnail(); ?>
                        				<p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'twentytwelve' ); ?></p>
                        				<?php get_search_form(); ?>
                    			</div><!-- .entry-content -->
                			</article><!-- #post-0 -->
    
                		<?php endif; wp_reset_query(); ?>
    
            </div><!-- #content -->
        </div><!-- #primary -->
    
    <?php get_footer(); ?>
    Michael

    (@alchymyth)

    what is the output of the body_class() of your front page?

    this should have a CSS class which reflects the file name of the used template.

    you can find this in the body tag when you view the source code of your site in the browser.

    http://codex.wordpress.org/Function_Reference/body_class

    Thread Starter Christine357

    (@christine357)

    <body class="home page page-id-5 page-template page-template-homeTemplate-php logged-in admin-bar no-customize-support custom-background custom-font-enabled full-width">

    That?

    Michael

    (@alchymyth)

    the issue is your custom query using query_posts() which alters the query results so that the posts ‘forgets’ that it is on a page template;

    try to rewrite the loop using a custom query based on WP_Query();
    ( http://wordpress.stackexchange.com/questions/50761/when-to-use-wp-query-query-posts-and-pre-get-posts )

    example:

    <?php
    /**
     * Template Name: Page of Posts
     *
     * for a child theme of Twenty_Twelve
     */
    
    get_header( 'home' ); ?>
    
            <div id="primary" class="site-content">
                    <div id="content" role="main">
    
    	<div id="aboutHurkyWrap">
    		<div>Mission Statement</div>
    		<p>We seek success; not to step in the path of the established, but to leap away from the prevalent into a class of our own.  By developing a self-nurturing, ecosystem, we’ll harvest the finest natural ingredients to create our handcrafted brews and ciders.  More importantly, it is essential that we form a companionship within our community, help and donate to those in need, all while supporting the increasing health of our local environment. As we climb toward perfection, we'll make a point to share our product with all the great people around us.</p>
    	</div>
    
                    <?php
                            $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
                            $args= array(
                                    'category_name' => 'uncategorized', // Change this category SLUG to suit your use; or see for query parameters http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
                                    'paged' => $paged,
    				'posts_per_page' => 3,
    				'post_type' => 'post',
    );
                            $template_query = new WP_Query($args);
                            if( $template_query->have_posts() ) : ?>
    
    <div id="blogWrapTitle"><a href="http://hurkybird.com/blog-2/">Blog</a></div>
    
                			<?php while ( $template_query->have_posts() ) : $template_query->the_post(); ?>
                   				<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    						<!-- Adds the 140x140 thumbnail/featured image -->
            <div class="excerpt-thumb">
    	<a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'twentytwelve' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark">
                <?php the_post_thumbnail('excerpt-thumbnail', 'class=alignleft'); ?>
                </a>
            </div>
    						<div id="title_summary-wrap">
    						<header class="entry-header">
    							<h1 class="entry-title">
    								<a href="<?php the_permalink(); ?>" rel="bookmark"><?php the_title(); ?>
    							</h1>
    
    							<?php twentytwelve_entry_meta(); ?>
    						</header><!-- .entry-header -->
    
    						<div class="entry-summary">
    							<?php the_excerpt(); ?>
    						</div><!-- .entry-summary -->
    						</div>
    
    						<footer class="entry-meta">
    							<!-- meta was here -->
    							<?php edit_post_link( __( 'Edit', 'twentytwelve' ), '<span class="edit-link">', '</span>' ); ?>
    						</footer><!-- .entry-meta -->
    	</article><!-- #post -->
                    				<?php comments_template( '', true ); ?>
                					<?php endwhile; // end of the loop. ?>
    
                		<?php else : ?>
                			<article id="post-0" class="post no-results not-found">
                    			<header class="entry-header">
                        				<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentytwelve' ); ?></h1>
                    			</header>
                    			<div class="entry-content">
    <?php the_post_thumbnail(); ?>
                        				<p><?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'twentytwelve' ); ?></p>
                        				<?php get_search_form(); ?>
                    			</div><!-- .entry-content -->
                			</article><!-- #post-0 -->
    
                		<?php endif; wp_reset_postdata(); ?>
    
            </div><!-- #content -->
        </div><!-- #primary -->
    
    <?php get_footer(); ?>
Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Remove Tags From Excerpt’ is closed to new replies.