Site logo

Archived topic

Header element shortcode

14 replies · Started by Are Martin on December 5, 2018

Viewing posts 1–15 of 15

Hi Tom,

I´m using the header element and displaying entry-meta using a shortcode within the page-hero on this page

https://www.fysionett.no/ikke-lenger-nodvendig-med-henvisning-til-fysioterapi/

I´ve disabled the content title. However, as you can see the entry-meta is still displaying so now it´s displayed twice. I´ve tried to find the right combination of css selectors to remove the entry-meta from the entry-header only using display:none, but I can´t figure it out. How can I remove this without also removing the entry-meta displaying in the header element?

No problem :)

Sorry, it did not work that well after all... This css removes the entry-header on all posts. I only want it to be removed on the posts using that particualr shortcode and the header element.

Sorry have you tried using the template tags? Like using this in page hero content?
{{post_date}} {{post_author}}

I´ve tried them as well but the entry-header is still displaying

Weird. I was not able to duplicate that on my install - When I use {{post_date}} {{post_author}} as page hero content with the customizer options set to display, then the meta in the content is automatically removed: https://www.screencast.com/t/KYkLDW12ZD

Can you try that method again and let me have a look? Thanks!

I´ve used {{post_date}} in the header element now. If you use the link above you can check it out

How are you adding the entry meta in the content?

That's not the default style.

I figured it out

I used this snippet to display all meta in a single line.

/**
 * CSS also required, see: http://generatepress.com/forums/topic/all-meta-in-one-single-line/#post-108079
 */

if ( ! function_exists( 'generate_posted_on' ) ) :
/**
 * Prints HTML with meta information for the current post-date/time and author.
 */
function generate_posted_on() {

	if ( 'post' !== get_post_type() ) 
		return;
		
	$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
	if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) )
		$time_string .= '<time class="updated" datetime="%3$s" itemprop="dateModified">%4$s</time>';

	$time_string = sprintf( $time_string,
						   
	    esc_attr( get_the_date( 'c' ) ),
		esc_html( get_the_date() ),
		esc_attr( get_the_modified_date( 'c' ) ),
		esc_html( get_the_modified_date() )
	);

	printf( __('<span class="posted-on">%1$s</span> <span class="byline">%2$s</span>', 'generate' ),
		sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
			esc_url( get_permalink() ),
			esc_attr( get_the_time() ),
			$time_string
		),
		sprintf( '<span class="author vcard" itemtype="http://schema.org/Person" itemscope="itemscope" itemprop="author">%1$s <a class="url fn n" href="%2$s" title="%3$s" rel="author" itemprop="url"><span class="author-name" itemprop="name">%4$s</span></a></span>',
			__( 'av','generate'),
			esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
			esc_attr( sprintf( __( 'Se flere artikler av %s', 'generate' ), get_the_author() ) ),
			esc_html( get_the_author() )
		)
	);
	
	$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generate' ) );
	if ( $categories_list ) {
		printf( '<span class="cat-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
			_x( 'Categories', 'Used before category names.', 'generate' ),
			$categories_list
		);
	}

	$tags_list = get_the_tag_list( '', _x( ', ', 'Used between list items, there is a space after the comma.', 'generate' ) );
	if ( $tags_list ) {
		printf( '<span class="tags-links"><span class="screen-reader-text">%1$s </span>%2$s</span>',
			_x( 'Tags', 'Used before tag names.', 'generate' ),
			$tags_list
		);
	}
	
	if ( ! post_password_required() && ( comments_open() || get_comments_number() ) ) {
		echo '<span class="comments-link">';
		comments_popup_link( __( 'Leave a comment', 'generate' ), __( '1 Comment', 'generate' ), __( '% Comments', 'generate' ) );
		echo '</span>';
	}
}
endif;

if ( ! function_exists( 'generate_entry_meta' ) ) :
/**
 * Remove footer entry meta
 *
 */
function generate_entry_meta() {

	return '';
	
}
endif;

I had forgotten about that. When I deactivate the snippet it works like it should :)

However, if I use the shortcode the entry-header doesn´t disappear. (it,s just convenient to use shortcode because it´s already styled)

Not sure what you mean?

If you want the meta to be removed when they are added in page hero, using template tags is the way to go.

I agree :) Thanks for your help!

No problem :)

This archived topic is closed to new replies.