[Plugin: Microkid’s Related Posts] Using variable from other function
-
Hi there,
I’m pretty new with WordPress and I have a question about plugin: Microkid’s Related Posts.
I’ve added an extra field in db table ‘wp_post_relationships’ so I can separate different related posts. The variable $related_post_title is uses in other functions of this plugin. Therefore I want to use $related_post_title to help me do this.
However, $related_post_title seems to be empty in the function where i’m trying to use it. I works when I fill $related_post_title manually.Here is my code.. How can I use $related_post_title in this function?
function MRP_save_relationships( $post_id, $related_posts, $related_post_title ) { global $wpdb; // First delete the relationships that were there before MRP_delete_relationships( $post_id ); // Now add/update the relations if( $related_posts ) { foreach( $related_posts as $related_post) { if($related_post_title == "something"){ $relation_type = 2; } else{ $relation_type = 1; } $related_post = (int) $related_post; $query = "INSERT INTO ".$wpdb->prefix."post_relationships VALUES( $post_id, $related_post, $relation_type)"; $result = $wpdb->query( $query ); } } }
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘[Plugin: Microkid’s Related Posts] Using variable from other function’ is closed to new replies.