Site logo

Archived topic

Display Entry Meta – Author, category a specific tag

11 replies · Started by webcréateur on June 27, 2019

Viewing posts 1–12 of 12

Hi there,

We have a tricky requirement as regards entry Meta specifications.

Short background information:
We have a small weekly print newspaper with content that is also published online.

The weekly publications are currently tagged as follows: "Issue 21 June 2019" / "Issue 14 June 2019" etc. to be able to filter by a specific issue. In addition, we use categories such as “politics”, “culture” etc.

In general, we have 2 requirements.

1. How do I get it to display the Entry Post Meta data in the single posts as follows?
Author | Category | Issue 21 June 2019 (depending on issue)

Is this requirement possible with the new Post Meta ordering?
Like here

2. On the start page we use WP Show Posts with setting Post type “post” and Taxonomy “category”. In settings Meta I can uncheck to show date but how can I show a specific Issue (Tag) so the entry meta is displayed like our requirement:
Author | Category | Issue 21 June 2019 (depending on issue)

If I change WP Show Posts to the Taxonomy post_tag I can define a specific tag but the category disappears …

I would be grateful if you could help or have ideas on how to solve this requirement.

Is there a solution to create, own Meta data (similar to categories) and output it at the right place?

Using: GeneratePress Theme + GP Premium + Dispatch from Site Library

Thank you!

Hi there,

This should be possible like this:

add_filter( 'generate_header_entry_meta_items', function() {
    return array(
        'author',
        'categories',
        'date',
    );
} );

add_filter( 'generate_footer_entry_meta_items', function( $items ) {
    return array_diff( $items, [ 'categories' ] );
} );

WP Show Posts doesn't have a system like this yet, unfortunately. It has the standard option to show the categories/terms of the current post, but that's about it without custom coding (hooking into the post boxes).

Hi there,

thank you very much.

But it could not solve our requirement.

We created/registered a new taxonomy for the issues like mentioned in: https://codex.wordpress.org/Function_Reference/register_taxonomy

add_action( 'init', 'create_ausgabe_tax' );

function create_ausgabe_tax() {
	
	$labels = array(
		'name'              => _x( 'Ausgaben', 'taxonomy general name', 'textdomain' ),
		'singular_name'     => _x( 'Ausgabe', 'taxonomy singular name', 'textdomain' ),
		'search_items'      => __( 'Ausgaben Suchen', 'textdomain' ),
		'all_items'         => __( 'Alle Ausgaben', 'textdomain' ),
		'parent_item'       => __( 'Übergeordnete Ausgabe', 'textdomain' ),
		'parent_item_colon' => __( 'Übergeordnete Ausgabe:', 'textdomain' ),
		'edit_item'         => __( 'Ausgabe Bearbeiten', 'textdomain' ),
		'update_item'       => __( 'Update Ausgabe', 'textdomain' ),
		'add_new_item'      => __( 'Neue Ausgabe erstellen', 'textdomain' ),
		'new_item_name'     => __( 'Ausgabe vom', 'textdomain' ),
		'menu_name'         => __( 'Ausgabe', 'textdomain' ),
	);
	
	register_taxonomy(
		'ausgabe',
		'post',
		array(
			'label' => __( 'Ausgabe' ),
			'labels'=>$labels,
			'rewrite' => array( 'slug' => 'ausgabe' ),
			'hierarchical' => true,
		)
	);
}

The tayonomy is called "ausgabe".

How do I get it to display the new taxonomy "ausgabe" in Entry Post Metadata in the single posts as follows?

Author | Category | Issue 21 June 2019 (=> this is a new taxonomy)

I tried this (like mentioned here: https://generatepress.com/generatepress-2-3/)

add_filter( 'generate_header_entry_meta_items', function() {
    return array(
	'author',
        'categories',
	'ausgabe',
    );
} );

This does not work. :(

Any solutions?

Thank you.

Best regards.

Since you want to add it after the date, we need to filter the date portion of the entry meta:

add_filter( 'generate_post_date_output', function( $output ) {
    $terms = get_the_term_list( get_the_ID(), 'ausgabe', '', ', ' );

    return $output . ' | ' . $terms;
} );

Let me know :)

Thank you, but I'm afraid it doesn't work.

We don't want to show the date at all.

we only want to have the custom taxonmy displayed in third place only in single posts.

Author | Category | Custom taxonmy

In that case, try this:

add_filter( 'generate_category_list_output', function( $output ) {
    $terms = get_the_term_list( get_the_ID(), 'ausgabe', '', ', ' );

    return $output . '<span class="terms"> | ' . $terms . '</span>';
} );

Hello, Tom,

Thank you so much.

The snippet works :), but the new taxonomy also appears after the post (footer.entry-meta).

Is it possible to display the new taxonomy in such a way that it is only displayed above the single posts?

And if a post has no custom taxonomy only the seperater " | " is displayed. Possible to hide the seperater, if no custom taxonomy is set in the post?

Thank you.

Best regards.

Are you wanting to remove categories from the bottom of the post? Since we're filtering the categories, it's not possible to only target one area if they're displaying in multiple spots. We might be able to use CSS, but I'd have to see the page.

Hi Tom,

Thank you so much. It worked! :)

Best regards!

You're welcome :)

This archived topic is closed to new replies.