• 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)
  • Hi Tim,

    Can you explain a little more what it is exactly that you are trying to establish?

    regards,
    M.

    Thread Starter tim-dpi

    (@tim-dpi)

    Hi Microkid,

    I want to extend your plugin with the option ‘Relationship type’. So you can select what kind of relation your related post is. This relationship type can be used only show related posts from a specific relationship type.

    In other words, I want to categorize the related posts

    I see your location is Amsterdam, are you Dutch?

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.