Forum Replies Created
-
AuthorPosts
-
te1Member
Hi all,
I'm bumping this post as what I tried didn't work.
Any help is much appreciated.
te1MemberHi pxforti,
I tried your approach but it didn't work.
Here is my code:
function move_post_title() { if ( !is_single() ) return; //* Reposition the entry header remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_open', 5 ); remove_action( 'genesis_entry_header', 'genesis_entry_header_markup_close', 15 ); remove_action( 'genesis_entry_header', 'genesis_do_post_title' ); add_action( 'genesis_before_content', 'custom_genesis_entry_header_markup_open', 5 ); function custom_genesis_entry_header_markup_open() { $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'full' ); $video = get_field('featured_video'); if($video) { printf( '<header %s><video src="' . $video . '" poster="' . $image[0] . '" width="" height="" controls preload></video>', genesis_attr( 'entry-header' ) ); } else if(!empty($image)) { printf( '<header %s style="background-image:url(' . $image[0] . ');">', genesis_attr( 'entry-header' ) ); } else { printf( '<header %s style="background-image:url(' . get_stylesheet_directory_uri() . '/images/fire-risk-assessment-bg.jpg);">', genesis_attr( 'entry-header' ) ); } } add_action( 'genesis_before_content', 'genesis_entry_header_markup_close', 15 ); add_action( 'genesis_before_content', 'genesis_do_post_title' ); }
Please can you help me with this as I am still learning.
Thank you.
te1Member@Badlywired I figured it out! Thanks for your pointers towards this.
Here is the working code:
add_filter( 'genesis_attr_entry', 'custom_attributes_entry' ); function custom_attributes_entry( $attributes ) { global $post; $terms = wp_get_post_terms( $post->ID, 'sa_tax_sources', array('fields' => 'slugs') ); $typename = implode(' ', $terms); $attributes['class'] .= ' '. $typename; return $attributes; }
te1Member@Badlywired Ok, I understand. Yes, thank you for your pointers, they're a great help.
te1Member@Badlywired I now get this error: PHP Catchable fatal error: Object of class stdClass could not be converted to string in /wp-content/themes/genesis-sample/functions.php on line 219
te1Member@Badlywired I tried using your version but I get this error? PHP Parse error: syntax error, unexpected ',' in /wp-content/themes/genesis-sample/functions.php on line 222
te1Member@Badlywired Right, I'll give that a go...
te1Member@Badlywired I tried your code first but it didn't work? It didn't break anything but nothing showed up...
"I assume you want the taxonomy term used on that specific post, not all of them?" - Yes, this is what I'm trying to achieve.
I appreciate your help.
te1MemberMaybe something like this?
add_filter( 'genesis_attr_entry', 'custom_attributes_entry' ); function custom_attributes_entry( $attributes ) { $attributes['class'] .= ' ', array( 'class' => $typename); return $attributes; }
te1Member@Ren Ventura Yes that worked as I've managed to add a class of 'test' to the article entry, but how do I add a class using the variable $typename?
$terms = get_terms( 'sa_tax_sources' ); $typename = $terms[0]->name;
Any help is much appreciated.
te1MemberHi 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.
te1MemberI managed to achieve this with this code:
add_action( 'genesis_after_header', 'relocate_entry_title_singular' );
function relocate_entry_title_singular() {if ( ! is_singular() )
return;
echo '<div class="entry-header"><div class="wrap">';
genesis_do_post_title();
echo '</div></div>';remove_action( 'genesis_entry_header', 'genesis_do_post_title' );
}
te1MemberHi,
Thank you for the response.
This would work but I have added a structural wrap to the site inner.
Do you have another suggestion?
-
AuthorPosts