Community Forums › Forums › Archived Forums › Design Tips and Tricks › Include specific post ID option in Foodie Featured Posts Widget
Tagged: featured posts widget, foodie pro
- This topic has 10 replies, 3 voices, and was last updated 7 years, 1 month ago by
Victor Font.
-
AuthorPosts
-
September 20, 2018 at 1:02 pm #223323
Deluxe Designs
MemberI 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.
September 20, 2018 at 2:54 pm #223324Brad Dalton
ParticipantIf 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.
September 20, 2018 at 9:31 pm #223333Deluxe Designs
MemberOk, 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.
September 21, 2018 at 2:18 pm #223344Brad Dalton
ParticipantDid 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.
September 21, 2018 at 2:26 pm #223345Deluxe Designs
MemberThis 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'],
);`September 21, 2018 at 2:31 pm #223346Brad Dalton
ParticipantSeptember 21, 2018 at 2:34 pm #223347Deluxe Designs
MemberI removed it because I was really just guessing. I do not know what goes in the brackets.
'post__in' => $instance['post__in'],September 21, 2018 at 2:48 pm #223348Brad Dalton
ParticipantYou need to hard code the post i'd's.
Here's example arguments which show you how its done using the
'post__in'parameterhttps://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters
September 21, 2018 at 4:00 pm #223349Brad Dalton
ParticipantIf 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.
September 21, 2018 at 4:09 pm #223351Deluxe Designs
MemberI'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.
September 22, 2018 at 12:49 am #223359Victor Font
Moderator'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.
Regards,
Victor
https://victorfont.com/
Call us toll free: 844-VIC-FONT (842-3668)
Have you requested your free website audit yet? -
AuthorPosts
- The forum ‘Design Tips and Tricks’ is closed to new topics and replies.