- This topic has 10 replies, 3 voices, and was last updated 5 years, 2 months ago by .
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.
These forums are for general discussion on WordPress and Genesis. Official support for StudioPress themes is offered exclusively at My StudioPress. Responses in this forum are not guaranteed. Please note that this forum will require a new username, separate from the one used for My.StudioPress.
I understand that it is possible to add an option to include specific post IDs to the Foodie Featured Post Widget (similar to the GFWA plugin). From what I've read, you can use posts__in but I'm not sure what the code should be and where it should go in the foodie-featured-posts.php file.
Any assistance is appreciated.
If you search the foodie-pro folder for wp_query, you'll find the display.php file contains a array of $query_args you can modify/add to around line 19.
Ok, I see where to add the line of code, but my best guess as to what the code should be haven't worked. Any possibility you can spell it out for me? My trial and error is failing me.
Did you take a look at the post parameters for WP_Query?
What have you tried so far?
post__in should work.
Post your code please.
This is actually an older version of Foodie Pro that I've updated.
The args look like this:
`$query_args = array(
'post_type' => 'post',
'cat' => $instance['posts_cat'],
'showposts' => $instance['posts_num'],
'offset' => $instance['posts_offset'],
'orderby' => $instance['orderby'],
'order' => $instance['order'],
I removed it because I was really just guessing. I do not know what goes in the brackets.
'post__in' => $instance['post__in'],
You need to hard code the post i'd's.
Here's example arguments which show you how its done using the
If you're not a coder, another solution is to create a featured category and add the posts you want featured without the need to edit code.
that way you can use the widget settings.
I'm comfortable editing most code but this one has stumped me. I prefer to do this by creating an option to include IDs. Your site is the only one I found that has this answer.
'post__in' accepts an array of post ids as its argument. That array does not exist in the widget defaults. This means $instance won't work. You would either have to manually as in this example:
'post__in' => array('1', '2', '3', '4'),
Or add it to the defaults, create an entry point for a string of post ids in the widget interface, and convert the string to an array so post__in can accept it.
© 2023 WPEngine, Inc.