We're merging with GenerateBlocks! Learn more here.

[Support request] Display List Title or Category?

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support Display List Title or Category?

Tagged: 

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #12749
    Callista
    Participant

    Hi there,

    I’m trying to do something I thought was pretty simple, but maybe not. I want to display a short block (like 3) of the most recent posts of a particular category in descending order, with the name of the category they belong to above them. The title of the list would also work, since I’m calling it the same thing. I want to have a few different blocks of these posts on one page, so I need a way to distinguish them from one another.

    For example, if there is a page about Beauty and Style, I want to show a block of posts in the Beauty category, a block in the Style category, and a block in the Outfits category – each with a title above so users know what kind of posts are below it.

    However, I don’t see any options on where to show the list title or the category. I see documentation about the entry title, but I cannot find anything about the title of the post list itself. If I am just not looking in the right place, please point me in the right direction.

    Thanks!
    Best,
    Callista

    #12765
    Tom
    Keymaster

    Hi Callista,

    I wonder if something like this would work?:

    add_action( 'wpsp_before_header', function( $settings ) {
        // Lists we're targeting, replace with actual list IDs.
        $lists = array(
            '123',
            '456',
            '789'
        );
    
        if ( in_array( $settings['list_id'], $lists ) {
            echo '<div class="list-title">' . get_the_title( $settings['list_id'] ) . '</div>';
        }
    } );

    Let me know 🙂

    #12874
    Callista
    Participant

    Hi Tom,
    Thanks for your quick reply. I’m so sorry I haven’t responded before now. I’m having a crazy week at work. Will try this out soon (maybe over the weekend) and let you know. I truly appreciate your support.
    Have a great day!
    Best,
    Callista

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