Home › Forums › Pro Support › Show terms above post title?
- This topic has 12 replies, 4 voices, and was last updated 3 years, 1 month ago by
Tom.
-
AuthorPosts
-
October 4, 2018 at 3:31 pm #6104
christopher
ParticipantHi, I have a desire to show the terms of a post (the posts category) above the post title in one of my posts lists. It would look like:
(term)
(Post Title)
(excerpt)
(date posted)In the “meta” section settings, the only two options I am given is insert terms 1) below title or 2) below post.
Is there another way to achieve this?
Thanks for your time.
ChrisOctober 4, 2018 at 7:57 pm #6107Tom
KeymasterHey Chris,
Set it to below the title, then add this function:
add_action( 'wpsp_before_title', function( $settings ) { wpsp_meta( 'below-title', $settings ); } );
Let me know 🙂
October 9, 2018 at 10:14 am #6132christopher
ParticipantSo close! It shows up nicely above the Title now, but also still shows up below the title
(term)
title
(term)October 9, 2018 at 10:18 am #6133christopher
ParticipantOh, and also is now showing it on all wp-show posts instances ..
For example other lists where I don’t call the ‘terms’ and just date (which is a term i suppose) it displays:
(date)
Title
(date)October 9, 2018 at 7:50 pm #6136Tom
KeymasterYou would need to turn off the terms within the first list so they only display on top.
To make it happen on one list only, change your function to this:
add_action( 'wpsp_before_title', function( $settings ) { if ( 10 === $settings['list_id'] ) { wpsp_meta( 'below-title', $settings ); } } );
Updating
10
to whatever WPSP list ID you’re targeting.October 23, 2018 at 10:45 am #6294christopher
ParticipantThank you for that, targeting the specific list helped, but I still have the terms showing up (now) above AND below the title .. if I do not include Terms in that specific list, nothing shows up, so I’m a bit unclear what you mean about turning off terms within a list to only display on top?
In your code above is there a tweak to include some directive as to NOT display the terms under the post title?
October 23, 2018 at 6:49 pm #6297Tom
KeymasterAh, sorry about that. Try adding this as well:
remove_action( 'wpsp_after_title','wpsp_add_post_meta_after_title' );
March 4, 2020 at 12:04 pm #13727Stacie
ParticipantHi,
I found this thread when trying to do something similar however I have a question about the last reply (dated 10.23.2018). If I proceed with remove_action( ‘wpsp_after_title’,’wpsp_add_post_meta_after_title’ );
will this affect all lists or can I target just one list?
Thank you 🙂
StacieMarch 6, 2020 at 7:26 pm #13767Tom
KeymasterAh, that will affect all lists. I can’t think of a way to remove an action only for a specific list..
You could try targeting a specific page?
add_action( 'wp', function() { if ( is_page( 'my-page-slug' ) ) { remove_action( 'wpsp_after_title','wpsp_add_post_meta_after_title' ); } } );
April 16, 2020 at 2:00 pm #14844Bas
ParticipantHi Tom,
I’m using the snippet below you posted in this thread.
Is it possible to add more list ID’s to the snippet?add_action( 'wpsp_before_title', function( $settings ) { if ( 10 === $settings['list_id'] ) { wpsp_meta( 'below-title', $settings ); } } );
April 16, 2020 at 4:58 pm #14853Tom
KeymasterFor sure, you can do this:
add_action( 'wpsp_before_title', function( $settings ) { if ( 10 === $settings['list_id'] || 20 === $settings['list_id'] || 30 === $settings['list_id'] ) { wpsp_meta( 'below-title', $settings ); } } );
April 16, 2020 at 11:07 pm #14857Bas
ParticipantThank you for the quick fix 🙂
April 17, 2020 at 4:54 pm #14882Tom
KeymasterNo problem 🙂
-
AuthorPosts
- You must be logged in to reply to this topic.