• I am using Twentyfourteen. I want to add class=”hentry”></article but not sure where to put it. Content.php? Template-tags.php? With single.php, I have no idea where to place it as the file doesn’t have any classes. I want to add this to resolve one of many hAtom errors I have.

Viewing 15 replies - 31 through 45 (of 53 total)
  • Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Check your page’s source code to see whether the classes are there in your page.

    Right now your caching plugin is a big variable as to why you aren’t seeing the change on your website.

    Thread Starter Dan14

    (@dan14)

    I am getting the info, one sec Andrew

    Thread Starter Dan14

    (@dan14)

    This is what I have:

    id=”page” class=”hfeed site”><div
    class=”entry-header”><div
    class=”entry-meta”> <span
    class=”cat-links”><a
    </span></div><h1 class=”entry-title”>
    class=”entry-meta”> <span
    class=”entry-date”><a
    class=”entry-date update” datetime=”2014-07-16T22:44:13+00:00″>July 16, 2014 at 22:44 pm GMT</time></span> <span
    class=”byline”><span
    class=”author vcard”><a
    class=”url fn n”

    I do see entry date update but Google is ignoring it.., How come? This is why I thought I need that article class… Any ideas Andrew?

    Thread Starter Dan14

    (@dan14)

    I am not sure why Google is not recognizing it and it also doesn’t show up in structure data test.

    Andrew Nevins

    (@anevins)

    WCLDN 2018 Contributor | Volunteer support

    Copy the full source code and paste it into a PasteBin page, then link us that. The code you just posted seems very incomplete.

    Thread Starter Dan14

    (@dan14)

    I am going to try changing entry date to entry date updated in functions.php in the code you gave me

    Thread Starter Dan14

    (@dan14)

    This is my single.php:

    `// Start the Loop.
    while ( have_posts() ) : the_post();

    /*
    * Include the post format-specific template for the content. If you want to
    * use this in a child theme, then include a file called called content-___.php
    * (where ___ is the post format) and that will be used instead.
    */
    get_template_part( ‘content’, get_post_format() );

    Thread Starter Dan14

    (@dan14)

    The updated class is working for all posts but not for pages, any ideas why?

    what template files have you edited?
    what codes have you used or changed?

    for pages, have you also checked page.php and content-page.php?

    Thread Starter Dan14

    (@dan14)

    Hi Alcymyth, than you for your reply!! I am using this code in functions.php but for all pages and home page author and updated is not displaying:

    /**
     * Print HTML with meta information for the current post-date/time and author.
     *
     * @since Twenty Fourteen 1.0
     */
    function twentyfourteen_posted_on() {
    	if ( is_sticky() && is_home() && ! is_paged() ) {
    		echo '<span class="featured-post">' . __( 'Sticky', 'twentyfourteen' ) . '</span>';
    	}
    
    	// Set up and print post meta information.
    	printf( '<span class="entry-date"><a href="%1$s" rel="bookmark"><time class="entry-date updated" datetime="%2$s">%3$s</time></a></span> <span class="byline"><span class="author vcard"><a href="%4$s" rel="author">%5$s</a></span></span>',
    		esc_url( get_permalink() ),
    		esc_attr( get_the_date( 'c' ) ),
    		esc_html( get_the_date() ),
    		esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
    		get_the_author()
    	);
    }
    Thread Starter Dan14

    (@dan14)

    I think you gave me a good direction. How do I add updated class to the home page?

    as neither page.php nor content-page.php are using the ‘twentyfourteen_posted_on()’ function, the edited output cannot appear on static pages.

    do you need the output of the dates and author on the static pages?

    if yes, edit content-page.php, and insert the function at a similar location as it is in content.php;

    example:

    <?php
    /**
     * The template used for displaying page content
     *
     * @package WordPress
     * @subpackage Twenty_Fourteen
     * @since Twenty Fourteen 1.0
     */
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    	<?php
    		// Page thumbnail and title.
    		twentyfourteen_post_thumbnail();
    ?>
    	<header class="entry-header">
    		<?php the_title( '<h1 class="entry-title">', '</h1>' ); 		?>
    		<div class="entry-meta">
    			<?php twentyfourteen_posted_on(); ?>
    		</div><!-- .entry-meta -->
    	</header><!-- .entry-header -->
    
    	<div class="entry-content">
    		<?php
    			the_content();
    			wp_link_pages( array(
    				'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfourteen' ) . '</span>',
    				'after'       => '</div>',
    				'link_before' => '<span>',
    				'link_after'  => '</span>',
    			) );
    
    			edit_post_link( __( 'Edit', 'twentyfourteen' ), '<span class="edit-link">', '</span>' );
    		?>
    	</div><!-- .entry-content -->
    </article><!-- #post-## -->
    Thread Starter Dan14

    (@dan14)

    Hi Alchymyth, thank for your reply!! I need the updated class and author to be displayed in pages, yes. I am not sure I fully understood you. Do I need to edit the content-page.php with the above code and it will work or do I need to make any additional changes? I will edit the file in child theme.

    edit the content-page.php with the above code

    yes – replace the code of content-page.php with the suggested code; as far as I can see, no other changes needed.

    please test the results, and report if it needs fine tuning.

    Thread Starter Dan14

    (@dan14)

    Alchymyth, you are a life-saver!! Thank you!! It works for all pages. One more thing if you can help me with this issue, how can I also apply the call in functions.php (updated, author etc.) to the home page?

Viewing 15 replies - 31 through 45 (of 53 total)
  • The topic ‘Where to add class hentry in twentyfourteen’ is closed to new replies.