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!
Thread Starter
JoeMD
(@joemd)
Thanks for the reply. Already have a child theme set up so I’ll give the above a go. Thanks
Thread Starter
JoeMD
(@joemd)
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?
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…
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support
That code should go in your functions.php file of your Child Theme.
@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.
@wpyogi
Understood your words. Will adhere to the forum rules.
@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
Thread Starter
JoeMD
(@joemd)
@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.
Err, you have to put it in a PHP clause, like this:
<?php
// paste your functions here
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 */
Thread Starter
JoeMD
(@joemd)
@ 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?
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!
Thread Starter
JoeMD
(@joemd)
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?
Thread Starter
JoeMD
(@joemd)
P.S. What do you mean by “comment out” and “uncomment”?