Community Forums › Forums › Archived Forums › Design Tips and Tricks › Add a class to the genesis attribute entry
- This topic has 2 replies, 2 voices, and was last updated 11 years, 1 month ago by
te1.
-
AuthorPosts
-
April 22, 2015 at 2:59 am #148766
te1
MemberHi 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 '
';
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,
http://boxchilli.co/y-services/young-people
TobyApril 22, 2015 at 3:52 am #148774Brad Dalton
ParticipantPlease embed your code using a Gitub Gist as it breaks when you simply paste it.
April 22, 2015 at 3:58 am #148776te1
MemberHi 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.
-
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.