php - How to process shortcodes with post_id outside `The Loop` -


i'm reading emails using postie.

i'm using following filter process keywords inside email , convert them wp_postmeta items.

my postie_post_before filter.

//look ':keyword attribute:' tags , convert them '[keyword attribute]' function filter_content($post) {     $content = $post['post_content'];     $length = strlen($content);     $pos = array(         'name' => strpos($content, ':name '),         'cost' => strpos($content, ':cost '),         'price' => strpos($content, ':price ')     );     foreach ($pos $key => $value) {         if (false !== $value) {             $content[$value] = '[';             $value = strpos($content, ':', $value+1);             if ( (false !== $value) && (ctype_alnum($content[$value-1])) ) {$content[$value] = ']'; }         }     }     //if there no name attribute steal subject line.     if (strpos($content, '[name ') === false) {         $content = ' [name ' . $post['post_name'] . '] ' . $content;     }      $post['post_content'] = $content;     return $post; } 

my postie_post_after filter.

function resolve_shorttags($post) {     $content = $post['post_content'];     $content = do_shortcode($content);     $post['post_content'] = $content;     wp_update_post($post);     storedefaults($post['id']);     return $post; } 

because i'm running do_shortcode outside of the loop. get_the_id() not work. need post_id in order processing work correctly.

how pass post_id of posts process in resolve_shorttags() shorttag hooks?

remarks
know resolved if leave shorttags in , wait display time , loop process shorttags, want process data beforehand.

if there way process specific shortcodes or shortcode keys , attributes i'd happy also. can call handlers manually. don't want write own shortcode parser.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -