• 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

Add a class to the genesis attribute 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 › Design Tips and Tricks › Add a class to the genesis attribute entry

This topic is: not resolved

Tagged: framework, genesis, loop, php, Wordpress

  • This topic has 2 replies, 2 voices, and was last updated 11 years, 1 month ago by te1.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • April 22, 2015 at 2:59 am #148766
    te1
    Member

    Hi there,

    How do I add a class to the genesis attribute entry? I'm trying to add the variable $typename as a class/attribute to the article. I've tried with the following code but it's not working.

    <?php
    /*
    Template Name: Blog
    */

    //* Add custom body class to the head
    add_filter( 'body_class', 'add_body_class' );
    function add_body_class( $classes ) {
    $classes[] = 'y-services-blog';
    return $classes;
    }

    //* Replace standard loop with a custom loop
    remove_action( 'genesis_loop', 'genesis_do_loop' );
    add_action( 'genesis_loop', 'y_services_custom_loop' );
    function y_services_custom_loop() {
    global $wp_query, $more;

    $custom = array(
    'post_type' => array( 'post', 'sa-socialfeed' )
    );

    $defaults = array(); //* For forward compatibility
    $args = apply_filters( 'genesis_custom_loop_args', wp_parse_args( $custom, $defaults ), $custom, $defaults );

    $wp_query = new WP_Query( $args );

    if ( have_posts() ) :

    do_action( 'genesis_before_while' );
    echo 'Young People';
    echo '<div class="masonry-wrap">';
    while ( have_posts() ) : the_post();

    $terms = get_terms( 'sa_tax_sources' );
    $typename = $terms[0]->name;

    do_action( 'genesis_before_entry' );

    printf( '<article %s>', genesis_attr( 'entry', $typename ) );

    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 '</article>';

    do_action( 'genesis_after_entry' );

    endwhile; //* end of one post
    echo '</div>';
    do_action( 'genesis_after_endwhile' );

    else : //* if no posts exist
    do_action( 'genesis_loop_else' );
    endif; //* end loop
    }

    genesis();

    Cheers,
    Toby

    http://boxchilli.co/y-services/young-people
    April 22, 2015 at 3:52 am #148774
    Brad Dalton
    Participant

    Please embed your code using a Gitub Gist as it breaks when you simply paste it.


    Tutorials for StudioPress Themes.

    April 22, 2015 at 3:58 am #148776
    te1
    Member

    Hi there,

    Ok, I'll try and do that for next time. Do you have any suggestions on this?

    Here is a bit more of an in-depth explanation:

    I'm trying to achieve adding a class to the article depending on which post/social feed it is using the get_terms taxonomy. My test post is being displayed (the first/latest one) but it doesn't have the class of Twitter, for example, in the case of this argument. I've tried adding the variable $typename as a class/attribute to the article but it's not working.

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • The forum ‘Design Tips and Tricks’ 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