- This topic has 11 replies, 2 voices, and was last updated 4 years, 9 months ago by Tom.
-
AuthorPosts
-
June 27, 2019 at 12:02 am #942555webcréateur
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 here2. 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!
June 27, 2019 at 8:59 am #943046TomLead DeveloperLead DeveloperHi 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).
July 10, 2019 at 3:47 am #953793webcréateurHi 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.
July 10, 2019 at 9:15 am #954162TomLead DeveloperLead DeveloperSince 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 🙂
July 10, 2019 at 9:29 am #954177webcréateurThank 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
July 10, 2019 at 5:19 pm #954427TomLead DeveloperLead DeveloperIn 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>'; } );
July 11, 2019 at 12:34 am #954637webcréateurHello, 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.
July 11, 2019 at 9:59 am #955112TomLead DeveloperLead DeveloperAre 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.
July 11, 2019 at 10:27 am #955147webcréateurHi Tom,
Thank you.
I just provided login to the website through Account Issue:
https://generatepress.com/contact/Regrads.
July 11, 2019 at 9:01 pm #955534TomLead DeveloperLead DeveloperHi there,
Can you try the updated code above?: https://generatepress.com/forums/topic/display-entry-meta-author-category-a-specific-tag/#post-954427
Then add this CSS:
footer.entry-meta .terms { display: none; }
Let me know 🙂
July 11, 2019 at 11:11 pm #955574webcréateurHi Tom,
Thank you so much. It worked! 🙂
Best regards!
July 12, 2019 at 9:02 am #956019TomLead DeveloperLead DeveloperYou’re welcome 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.