[Resolved] Header element shortcode

Home Forums Support [Resolved] Header element shortcode

Home Forums Support Header element shortcode

Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #749179
    Are Martin

    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?

    #749194
    Leo
    Staff
    Customer Support

    Hi there,

    What shortcode are you using?

    Just to make sure, if you hide it using the customizer, both are removed?
    https://docs.generatepress.com/article/blog-content-layout/#single

    For CSS, this should work:

    .single .entry-header {
        display: none;
    }

    Let me know if this helps 🙂

    #749198
    Are Martin

    Thanks, that worked well! 🙂 I´m using this shortcode https://generatepress.com/forums/topic/display-post-meta-in-sections/#post-284619

    #749201
    Leo
    Staff
    Customer Support

    No problem 🙂

    #749204
    Are Martin

    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.

    #749207
    Leo
    Staff
    Customer Support

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

    #749208
    Are Martin

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

    #749217
    Leo
    Staff
    Customer Support

    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!

    #749223
    Are Martin

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

    #749243
    Leo
    Staff
    Customer Support

    How are you adding the entry meta in the content?

    That’s not the default style.

    #749420
    Are Martin

    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 🙂

    #749424
    Are Martin

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

    #749857
    Leo
    Staff
    Customer Support

    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.

    #750418
    Are Martin

    I agree 🙂 Thanks for your help!

    #750715
    Leo
    Staff
    Customer Support

    No problem 🙂

Viewing 15 posts - 1 through 15 (of 15 total)
  • You must be logged in to reply to this topic.