How to add a feature image dynamically / programatically / on-the-fly
-
I am dynamically adding a post using the filter
add_filter('the_posts', 'add_fake_post');
Note that I am NOT inserting a post into the database, this is a just in memory post.
The adding a post code goes like this:
function add_fake_post($content) { $post_array = array($content[0]); $prpost = <create a post object>; $post_array[1] = $prpost; for ($i = 2; $i <= $posts_count; $i++) { $post_array[$i] = $content[$i-1]; } return $post_array; }
My question is: how do I set the feature image for this post programatically/dynamically?
A donut for the person who helps me 🙂
Thanks!
- The topic ‘How to add a feature image dynamically / programatically / on-the-fly’ is closed to new replies.