- This topic has 16 replies, 3 voices, and was last updated 6 years, 2 months ago by Tom.
-
AuthorPosts
-
December 26, 2017 at 5:49 pm #457483Craig
Hello,
I’ve created a custom taxonomy called “writer” and would like to display that for my post meta rather than WP author.Should I…
1. Hide the author meta via customizer and insert my custom byline via hook?
2. Edit my child theme version of post-meta.php?
Thanks for any suggestions!
December 26, 2017 at 8:38 pm #457534TomLead DeveloperLead DeveloperI would go for #1.
Then you can hook your own code in using this hook: https://docs.generatepress.com/article/generate_after_entry_title/
Let me know if you need more info π
December 27, 2017 at 5:05 am #457729GabrieleHi,
I’m trying to display an ACF Pro field (read_time) as meta, only on post archive pages, instead of the post date and author.
Here is the code for display the custom field, please can you help me to write the full snippets?the_field('read_time');
December 27, 2017 at 10:42 am #457967TomLead DeveloperLead DeveloperYou would do something like this:
add_action( 'generate_after_entry_title', 'tu_custom_byline' ); function tu_custom_byline() { if ( function_exists( 'the_field' ) && is_archive() ) { the_field( 'read_time' ); } }
December 27, 2017 at 11:03 am #457981CraigTom…just a quick followup to my original question. Your new(ish) custom page headers are awesome. I hid post meta via customizer and created a page header using the {{post_terms.taxonomy}} template tag to pull in my custom taxonomy. Works great!
December 27, 2017 at 12:01 pm #458011TomLead DeveloperLead DeveloperAwesome! Glad you like it π
The Page Header will also automatically remove the post meta if it’s set in the Page Header on that page, so you can keep it elsewhere instead of hiding it globally in the Customizer.
December 27, 2017 at 12:03 pm #458015CraigJust noticed that…very slick! Props mate.
December 27, 2017 at 12:09 pm #458030GabrieleHi Tom,
it works very well, thanks a lot, but it needs a little finishing touch: how to add some text before the custom field, like “Read Time:” and after “Minutes”.
Also is it possible to show the custom field also in the main blog page (it seems that is not considered an archive page) ?December 27, 2017 at 8:20 pm #458193TomLead DeveloperLead DeveloperTry this:
add_action( 'generate_after_entry_title', 'tu_custom_byline' ); function tu_custom_byline() { if ( function_exists( 'the_field' ) && ! is_singular() ) { echo 'Read Time: '; the_field( 'read_time' ); echo ' Minutes'; } }
December 29, 2017 at 1:07 am #459051GabrieleWorks great.
Thanks again!December 29, 2017 at 9:43 am #459409TomLead DeveloperLead DeveloperYou’re welcome π
January 27, 2018 at 4:56 pm #481395GabrieleHi Tom,
a little follow up with that: I would like to show this custom field on the same line with post date and post author as the first element (now it appears in a different line below the post date and author).
I tried to put the function inside a entry-meta div but although it takes the css style of the other metas is still on another line as a second entry-meta div.
Please can you help me to show this custom field inline with other metas?January 28, 2018 at 12:39 am #481489TomLead DeveloperLead DeveloperAny chance you can link me to the page?
January 28, 2018 at 4:57 am #481584GabrieleSorry, I’m working offline but I can share with you a screenshot: https://www.dropbox.com/s/4hijca110wfvp9m/Articoli.jpg?dl=0 and this is the code I’m using for dislaying the ACF custom field for the new meta:
<?php if ( function_exists( 'the_field' ) && ! is_singular() ) : ?> <div class="entry-meta"> <?php echo 'Tempo di lettura: '; the_field( 'read_time' ); echo ' min'; ?> </div> <?php endif; ?>
As you can see I tried to wrap the function inside the entry-meta div but this simply create a new entry-meta div, instead I would like to display the new meta on a single line toegether with posta date and author.
January 28, 2018 at 10:10 am #481858TomLead DeveloperLead DeveloperIt’s really hard to tell without inspecting the code, but you could try this:
.entry-meta { display: inline-block; }
-
AuthorPosts
- You must be logged in to reply to this topic.