Black Friday sale! Get 25% off WPSP Pro! Discount automatically applied at checkout.

[Support request] Show terms above post title?

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Show terms above post title?

Tagged: ,

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #6104
    christopher
    Participant

    Hi, 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.
    Chris

    #6107
    Tom
    Keymaster

    Hey 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 🙂

    #6132
    christopher
    Participant

    So close! It shows up nicely above the Title now, but also still shows up below the title

    (term)
    title
    (term)

    #6133
    christopher
    Participant

    Oh, 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)

    #6136
    Tom
    Keymaster

    You 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.

    #6294
    christopher
    Participant

    Thank 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?

    #6297
    Tom
    Keymaster

    Ah, sorry about that. Try adding this as well:

    remove_action( 'wpsp_after_title','wpsp_add_post_meta_after_title' );

    #13727
    Stacie
    Participant

    Hi,

    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 🙂
    Stacie

    #13767
    Tom
    Keymaster

    Ah, 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' );
        }
    } );
    #14844
    Bas
    Participant

    Hi 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 );
        }
    } );
    
    #14853
    Tom
    Keymaster

    For 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 );
        }
    } );
    #14857
    Bas
    Participant

    Thank you for the quick fix 🙂

    #14882
    Tom
    Keymaster

    No problem 🙂

Viewing 13 posts - 1 through 13 (of 13 total)
  • You must be logged in to reply to this topic.