WordPress.org

Ready to get started?Download WordPress

Forums

Expound
[resolved] Getting More Control Over Featured Posts (21 posts)

  1. JoeMD
    Member
    Posted 10 months ago #

    First, let me say that I think Expound is a BEAUTIFUL theme. What really grabbed my attention is the way the first 5 featured posts are shown, with the large image and four thumbnails.

    However, I'm wondering if it's possible to gain a little more control over what is shown and how it behaves? Basically what I'd like to be able to do is pin a post so that it always appears as the first featured story but other featured stories appearing in the grid. Then, if there is no featured post, everything acts as normal.

    I saw in another post here that you can override the expound_get_featured_posts function in a child theme but I've no idea where to start with this. Any suggestions/ help would be wonderful. If what I'm looking to do is not possible, that's OK, but we don't know till we ask.

    Cheers.

    Site link - http://soniccollectors.com/?page_id=2 (main page is just a holder for now, this is how it will apear when the site is "live")

  2. Konstantin Kovshenin
    Member
    Theme Author

    Posted 10 months ago #

    Hey there, thanks for the kind words! Yeah, you have to create a child theme and override the expound_get_featured_posts function to return whatever query you like. For example:

    function expound_get_featured_posts() {
        return new WP_Query( array(
            'post__in' => array( 1, 2, 3 ),
        ) );
    }

    That will return posts with the ID of 1, 2 and 3 as the featured posts. You can learn more about querying in WordPress here: http://codex.wordpress.org/Class_Reference/WP_Query

    Hope that helps!

  3. JoeMD
    Member
    Posted 10 months ago #

    Thanks for the reply. Already have a child theme set up so I'll give the above a go. Thanks

  4. JoeMD
    Member
    Posted 9 months ago #

    Hey Konstantin,

    I tried adding the above code to my CSS editor, but it gives me little red crosses next to each line of code and even after saving it seems to have no effect. I had a look at the page you linked to for me, but it was very confusing. Would you able to explain things a little further?

  5. vinn95
    Member
    Posted 9 months ago #

    I'm stumbling on the above code.
    But I trust the code is all about the theme functions, functions.php file.
    When I add the above code to my functions php file the site goes blank.
    Seeking your help theme Author...

  6. Andrew
    Forum Moderator
    Posted 9 months ago #

    That code should go in your functions.php file of your Child Theme.

  7. WPyogi
    Volunteer Moderator
    Posted 9 months ago #

    @vinn95 - please do not interrupt other people's threads - if you need help start your own thread . The above code must go in a child theme - if you are putting it someplace else, that's why it's not working.

  8. vinn95
    Member
    Posted 9 months ago #

    @WPyogi
    Understood your words. Will adhere to the forum rules.

  9. Konstantin Kovshenin
    Member
    Theme Author

    Posted 9 months ago #

    @vinn95, make sure you're using a Child Theme and not adding the above code to the existing Expound theme itself. More about child themes here: http://codex.wordpress.org/Child_Themes

  10. JoeMD
    Member
    Posted 9 months ago #

    @Andrew Nevins - I created a functions.php file for my child theme and added the code but it just puts a line of text at the top of the site.

    URL - http://soniccollectors.com/sample-page/

    P.S. Changed the thread back to un-resoled.

  11. Konstantin Kovshenin
    Member
    Theme Author

    Posted 9 months ago #

    Err, you have to put it in a PHP clause, like this:

    <?php
    // paste your functions here
  12. vinn95
    Member
    Posted 9 months ago #

    Thanks Konstantin for your theme and reply.
    I have understood the basics of child theme and working on it.

    /* My apologies for interrupting in other's thread. I took over as the theme author had addressed me in this thread */

  13. JoeMD
    Member
    Posted 9 months ago #

    @ Konstantin Kovshenin - Err, I didn't reaslise this. This is a SUPPORT forum after all, that would suggest that we do not know every little aspect of coding. But thank you for your reply, will try it out when I get home.

    As an extension of this, is it possible to switch between dictating what posts appear as featured and just letting the newest posts show or does the above code have to be altered each time?

  14. Konstantin Kovshenin
    Member
    Theme Author

    Posted 9 months ago #

    Joe, that's fine, I just assumed you knew because you already had a child theme setup, etc., sorry about that!

    By default, Expound will "feature" your newest posts, unless you have set any to sticky. The snippet above shows a way to modify that behavior with code, so in theory you could easily grab, say, two predefined posts (by ID), and three latest (by date), then mix and add them to the featured sections. In practice, however, you *will* need some basic PHP knowledge to do that.

    If you just need to switch between a predefined set of 5 posts and 5 latest post, you can simply comment out the function you defined in your child theme, and uncomment it when you need it again.

    Hope this helps!

  15. JoeMD
    Member
    Posted 9 months ago #

    Thanks for that. I'm kind of lacking in php knowledge so maybe this might not be right for me. If I was going to mix pre-defined posts via ID and via date, what format does the date take?

    Also, I've set up the featured posts so it only shows posts with the "featured" tag via WP's Reading settings. With the above code override this or should I uncheck this setting?

  16. JoeMD
    Member
    Posted 9 months ago #

    P.S. What do you mean by "comment out" and "uncomment"?

  17. JoeMD
    Member
    Posted 9 months ago #

    P.S. What do you mean by "comment out" and "uncomment"?

    Don't worry about that, I figured it out.

    Just another thought; is it possible to have one of the featured posts dictated while the others automatically based on dates?

  18. Konstantin Kovshenin
    Member
    Theme Author

    Posted 9 months ago #

    > Just another thought; is it possible to have one of the featured posts dictated while the others automatically based on dates?

    Yes, that's what I said in my comment above: The snippet above shows a way to modify that behavior with code, so in theory you could easily grab, say, two predefined posts (by ID), and three latest (by date), then mix and add them to the featured sections.

  19. Konstantin Kovshenin
    Member
    Theme Author

    Posted 9 months ago #

    > Also, I've set up the featured posts so it only shows posts with the "featured" tag via WP's Reading settings. With the above code override this or should I uncheck this setting?

    Not entirely sure, but possibly. Best way to find out is to try it out :)

  20. Konstantin Kovshenin
    Member
    Theme Author

    Posted 9 months ago #

    > If I was going to mix pre-defined posts via ID and via date, what format does the date take?

    It does not take any format, it's just a "grab posts by date" query. You can learn more about querying in WordPress here: http://codex.wordpress.org/Class_Reference/WP_Query

  21. JoeMD
    Member
    Posted 9 months ago #

    Ok, great. Thanks.

Reply

You must log in to post.

About this Theme

About this Topic

Tags

No tags yet.