Site logo

Archived topic

Layout categories next to Meta, Pages with/without meta?

7 replies · Started by Morgan on March 23, 2021

Viewing posts 1–8 of 8

As intructed by David, I'm creating a new post for these related queries:

1. I’ve used the snippet below to get the categories appearing next to meta, and it works fine.
But can you pls tell me how I can have the exact archives cats/meta layout on all posts as well (and if there's a simpler way now to achieve the same)?

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;
	
	$date = apply_filters( 'generate_post_date', true );
	$author = apply_filters( 'generate_post_author', true );
	$categories = apply_filters( 'generate_show_categories', true );
	$tags = apply_filters( 'generate_show_tags', true );
	$comments = apply_filters( 'generate_show_comments', true );
		
	$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() )
	);
	
	// If our date is enabled, show it
	if ( $date ) :
		printf( '<span class="posted-on">%1$s</span>',
			sprintf( '<a href="%1$s" title="%2$s" rel="bookmark">%3$s</a>',
				esc_url( get_permalink() ),
				esc_attr( get_the_time() ),
				$time_string
			)
		);
	endif;
	
	// If our author is enabled, show it
	if ( $author ) :
		printf( ' <span class="byline">%1$s</span>',
			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>',
				__( 'by','generate'),
				esc_url( get_author_posts_url( get_the_author_meta( 'ID' ) ) ),
				esc_attr( sprintf( __( 'View all posts by %s', 'generate' ), get_the_author() ) ),
				esc_html( get_the_author() )
			)
		);
	endif;
	
	// Show the category and tags
	if ( 'post' == get_post_type() ) {

		$categories_list = get_the_category_list( _x( ', ', 'Used between list items, there is a space after the comma.', 'generate' ) );
		if ( $categories_list && $categories ) {
			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 && $tags ) {
			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
			);
		}
	}
	
	// Show the comments link
	if ( ! is_single() && ! post_password_required() && ( comments_open() || get_comments_number() ) && $comments ) {
		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' ) ) :
/**
 * Prints HTML with meta information for the categories, tags.
 *
 * @since 1.2.5
 */
function generate_entry_meta() 
{
}
endif;

2. Is there a way to specify which pages will have meta info? I.e. I'd like some pages with a plain title as per: http://screen.coach/attorneys/ , but would like to be able to create Pages with an author box &/or meta/date, etc.

If GPP 2.0 isn't live this week, then I guess I am in a hurry :)

GPP 2.0 will be entering beta today and should be a release candidate next week. That means the official release should be April 6/7 :)

Hi Morgan,

Just so you know, GPP 2.0 dynamic content only works with blocks that're from Generateblocks plugin, it DOES NOT work with WP blocks or blocks from other plugin.

Dynamic image doesn't have to be a container background image, there's a dynamic image block if you search GP when you add block.

We have some videos to show you how to use the dynamic feature, it should be helpful :)
https://www.youtube.com/channel/UCoHk-JZFs1N-iI2DQlIKVnA

Yes, I assumed that, it was a GenerateBlocks container, and as I said a dynamic img block wouldn't have worked as I needed a background featured image applied to a container to appear under post-titles, for my archive.

I was using as seemingly intended, but it wasn't working.
If this is isn't an existing feature (tho it should be!) why was it giving me the option to apply a dynamic background image to a container?

This archived topic is closed to new replies.