• Skip to main content
  • Skip to forum navigation

StudioPress

  • Shop for Themes
  • My StudioPress

Forum navigation

  • Home
  • General Genesis Discussions
  • StudioPress Themes
  • Genesis Blocks
    • Genesis Blocks
    • Genesis Custom Blocks
  • Retired Themes
  • FAQs
  • Forum Rules
  • Internationalization and Translations
  • Forum Bugs and Suggestions
  • Forum Log In

Are You Using The WordPress Block Editor?

Genesis now offers plugins that help you build better sites faster with the WordPress block editor (Gutenberg). Try the feature-rich free versions of each plugin for yourself!

Genesis Blocks Genesis Custom Blocks

Loop Using .hentry, Not .entry

Welcome!

These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.

Log In
Register Lost Password

Community Forums › Forums › Archived Forums › General Discussion › Loop Using .hentry, Not .entry

This topic is: not resolved

Tagged: Ajax, entry, hentry, loop

  • This topic has 5 replies, 2 voices, and was last updated 9 years, 9 months ago by Porter.
Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • March 27, 2016 at 8:41 pm #182348
    Porter
    Participant

    The home page loop for a client is using .entry, and the formatting is great. I'm using ajax to pull in posts, using the a copy / paste of the original front-page loop they were using. For some reason, the ajax returned loop is using .hentry, not .entry, and the formatting is broke. To be clear, the default loop shows the same exact structure, but .entry, not .hentry. I changed .hentry to .entry in the inspector, and it fixed everything.

    I'm completely losing it trying to figure out how to fix this, any ideas?

    I've isolated the "issue" to this line, printf( '<article %s>', genesis_attr( 'entry' ) );
    If I change 'entry' to 'entryaaaaa', all of these classes aren't pulled in:

    post-14 type-post status-publish format-standard has-post-thumbnail hentry category-culture

    So that line, is pulling in all of the classes, but something is telling it to use hentry, not entry.

    if( $the_query->have_posts() ) :
    
        do_action( 'genesis_before_while' );
        while ( $the_query->have_posts() ) : $the_query->the_post();
    
          do_action( 'genesis_before_entry' );
          echo '<div class="article-bootstrap col-xs-6 col-sm-4">';
            printf( '<article %s>', genesis_attr( 'entry' ) );
              echo '<div class="entry-wrapper">';
                do_action( 'genesis_entry_header' );
                do_action( 'genesis_before_entry_content' );
                printf( '<div %s>', genesis_attr( 'entry-content' ) );
                  do_action( 'genesis_entry_content' );
                echo '</div>';
                do_action( 'genesis_after_entry_content' );
                do_action( 'genesis_entry_footer' );
              echo '</div>';
            echo '</article>';
          echo '</div>';
          do_action( 'genesis_after_entry' );
    
        endwhile; //* end of one post
        do_action( 'genesis_after_endwhile' );
    
      else : //* if no posts exist
        do_action( 'genesis_loop_else' );
      endif; //* end loop

    Buy me a beer? | Try DigitalOcean VPS Hosting

    March 29, 2016 at 7:54 am #182428
    Victor Font
    Moderator

    For whatever reason, your code is bypassing the HTML5 check. Hentry is removed in the genesis_entry_post_class function located in genesis/lib/structure/post.php. The function checks for HTML5 support and removes hentry if true. What happens if you remove the ajax call and use the standard loop?


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    March 29, 2016 at 1:53 pm #182479
    Porter
    Participant

    The code from the standard loop is simply copy / pasted into functions.php, with slight alterations to wrap certain elements in div tags (not ideal, but I didn't write it). That being said, I found the cause! Line 84 of genesis/lib/structure/post.php

    if ( is_admin() ) {
    		return $classes;
    	}

    The is_admin function is returning true, because all ajax calls in Worpdress (at least, from the learning I've done this last week), go through the admin area, via admin-ajax.php. Since it's going through the admin, this check is exiting before reaching the rest of the function that displays the posts as I'd like them too.

    Now I'm sick, and a bit out of my comfort zone, but isn't that somewhat of a bug on the end of Genesis? If this is indeed the standard behavior for an ajax call (going through admin), we don't want to tamper with the formatting as if we're in the admin panel. I can't think of a better check off the top of my head, but surely that boolean check can be expanded to exclude when an ajax call is happening, or add an && like so:

    if ( is_admin() && current_user_can( $capability ) ) {
    		return $classes;
    	}

    Perhaps with the lowest common privilege, that check would suffice to know if you're on the admin dashboard, vs doing ajax? (list of privileges)

    Again, I'm just kind of thinking out loud here, so please correct me / let me know what you think.

    PS - I "fixed" my issue with this javascript, but it's obviously a hack-job, and I'd like to continue the dialogue above.

    $('.status-publish').toggleClass('hentry entry');


    Buy me a beer? | Try DigitalOcean VPS Hosting

    March 29, 2016 at 5:57 pm #182492
    Victor Font
    Moderator

    I could be wrong, but I don't think Genesis was updated to work with WordPress Ajax calls yet, so no, it wouldn't be a bug if it doesn't support the feature.


    Regards,

    Victor
    https://victorfont.com/
    Call us toll free: 844-VIC-FONT (842-3668)
    Have you requested your free website audit yet?

    March 29, 2016 at 7:36 pm #182497
    Porter
    Participant

    There are "how to" articles pertaining to WordPress and Ajax dating back to 2011 and very likely long before, if it hasn't been updated to "support" it, it never will be (unless they overhaul completely to help with the REST API).

    I'm still leaning towards it being an overlooked case, as I've see a few in WordPress core pertaining to these kinds of checks (images being returned with size modifications that weren't meant for the dashboard).

    What's the best way to contact StudioPress to get an official response?


    Buy me a beer? | Try DigitalOcean VPS Hosting

    March 29, 2016 at 9:38 pm #182499
    Porter
    Participant

    I did a bit of digging around, and while there may be a more elegant solution, this seems to the accepted way to circumvent the issue. Simply change the sole is_admin() function call, to:

    if ( is_admin() && defined('DOING_AJAX') && !DOING_AJAX )

    I'm not 100% sure where in the admin area this check shows up, or what id does, but I think this works. I'm going to edit my Genesis framework files to include this change, unless someone can tell me what it might break. I put in a ticket to support, hopefully they take a peak, and even better consider patching the next minor release.


    Buy me a beer? | Try DigitalOcean VPS Hosting

  • Author
    Posts
Viewing 6 posts - 1 through 6 (of 6 total)
  • The forum ‘General Discussion’ is closed to new topics and replies.

CTA

Ready to get started? Create a site or shop for themes.

Create a site with WP EngineShop for Themes

Footer

StudioPress

© 2026 WPEngine, Inc.

Products
  • Create a Site with WP Engine
  • Shop for Themes
  • Theme Features
  • Get Started
  • Showcase
Company
  • Brand Assets
  • Terms of Service
  • Accptable Usse Policy
  • Privacy Policy
  • Refund Policy
  • Contact Us
Community
  • Find Developers
  • Forums
  • Facebook Group
  • #GenesisWP
  • Showcase
Resources
  • StudioPress Blog
  • Help & Documentation
  • FAQs
  • Code Snippets
  • Affiliates
Connect
  • StudioPress Live
  • StudioPress FM
  • Facebook
  • Twitter
  • Dribbble