Site logo

[Support request] Featured Blog At Top of Blog Category

Home Forums Support [Support request] Featured Blog At Top of Blog Category

Home Forums Support Featured Blog At Top of Blog Category

Viewing 14 posts - 1 through 14 (of 14 total)
  • Author
    Posts
  • #2502935
    Ella

    Hi there,

    I have category pages for my blog sections, which list all my latest posts within that category, but I wondered if it was possible to highlight a featured post at the top of them? EG here I want to add a master “Self Love Challenge” post, which is easy to find, then we display the rest of the posts relating to this, below it: https://www.forgettingfairytales.com/category/self-love/

    Is this possible on a category page, or would I have to create a new normal page? And if I did – could I duplicate the exact format so it stays looking exactly like this? Then just add the extra “featured post” blog feature… and then how would I add that in?

    Any guidance would be much appreciated!

    Thanks so much,
    Ella

    #2503289
    David
    Staff
    Customer Support

    Hi there,

    Tricky one.
    One possibility is to:

    1. Add a Tag of featured to the Post you want to display at the top.
    2. Add this PHP Snippet to your site:

    add_action( 'loop_start', function( $q ) {
        if( $q->is_main_query() && $q->is_category() )
            usort( $q->posts, function( $a, $b ){
                return -1 * has_tag( 'featured', $a ) + 1 * has_tag( 'featured', $b );            
            });
    }, 10, 2 );

    If that works we can talk about making that first post look different

    #2505875
    Ella

    That doesn’t seem to have worked… unless I added it into the wrong place? Does a PHP snippet go under “Customise” and “Additional CSS” as that’s where I added it? I did also have a #Featured tag already but tried it with just Featured so that should have been okay there?

    Let me know!

    Thanks,
    Ella

    #2506162
    David
    Staff
    Customer Support

    Its PHP this doc explains:

    https://docs.generatepress.com/article/adding-php/

    TLDR:
    Are you using a Child Theme?
    If Yes, then the PHP goes in the Child Theme > functions.php
    If No, then install the Code Snippets plugin ( link in the above doc ) and Add New Snippet to add the PHP

    #2515250
    Ella

    Okay, added via Code Snippets and it didn’t work.

    Instead of trying to feature a post on the top, can we instead, simply add a text box onto the category pages.

    EG on the homepage, we have the “welcome to forgetting fairytales” text box: https://www.forgettingfairytales.com I’d like to be able to have text like this at the top of the category pages to introduce what it’s all about. EG above where the posts list starts here: https://www.forgettingfairytales.com/category/breakups/

    Is this possible, and in an easier way at all?

    Thanks so much,
    Ella

    #2515406
    David
    Staff
    Customer Support

    If you edit a Category – do you have text in the Description ?
    If so that could hooked into your page. Let me know.

    #2516943
    Ella

    Yes there’s a description box 🙂 Let me know what to do next! Thanks 😀

    #2517262
    David
    Staff
    Customer Support

    Whilst viewing a category page, use the Admin Bar > Elements menu shortcut to edit the: Archive Header Block element.
    Beneath the Headline that is showing the title.
    Add a GP Dynamic Content Block and set its Type to: Term Description.

    That will print the description below the title on archive pages..

    #2517272
    Ella

    Amazing, thank you very much. Is there a way I can make the text smaller – particularly on mobile but also on desktop too? As even just a few sentences there, pushes the blog posts right down when it’s at that size on mobile. And the text on Desktop is also bigger than the logo and page titles too so it looks a little “shouty!” Please see here: https://www.forgettingfairytales.com/category/single/

    Thanks,
    Ella

    #2517281
    David
    Staff
    Customer Support

    Edit the element.
    Select the Container Block that the title and description is inside.
    In its Typography settings, set a font size for Desktop and for Mobile. The description will inherit that size.

    For the Title, you can select its Headline Block and change its Typography font size

    #2517306
    Ella

    Where is this sorry? I can’t see the Typography settings. I can only see editor width, element type, quick hooks, etc to the right, then below its just location etc. Am I looking in the wrong place?

    Thanks,
    Ella

    #2517310
    David
    Staff
    Customer Support
    #2517321
    Ella

    Oh perfect, thank you so much! I didn’t actually even know that was there. You’re fantastic. All sorted now then 😀

    #2518221
    David
    Staff
    Customer Support

    Glad to be of help 🙂

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