Have post appear on top of front page after image upload- can´t grab post id
-
Hi!
Thanks for a great plugin!
I have a static front page showing latest posts, and trying to get a post which has an image uploaded to it appear on top of the front page.
Tried the “sort posts by most recent modified approach” which worked manually for post id 110, but not programmatically.
I put this in index.php to sort by modified:
<?php if ( is_home() ) { query_posts($query_string . '&orderby=modified&order=desc'); } ?>
I put this in single.php to get the upload form:
<?php echo do_shortcode( '[fu-upload-form]' ); ?>
And I put this in functions.php to update post 110:
add_action( 'fu_after_upload', 'my_fu_after_upload' ); function my_fu_after_upload( $attachment_ids ) { $my_post = array( 'ID' => 110, 'post_content' => 'updated content' ); wp_update_post( $my_post ); }
This all works fine, with post 110 appearing on top of my front page after image upload, but I just can´t figure out how to grab the post id for any post, not manually just for post 110.
Any input on how to grab the post id in the action would be highly appreciated 🙂
(I run WP 3.8.1 with twentytwelve theme)
- The topic ‘Have post appear on top of front page after image upload- can´t grab post id’ is closed to new replies.