Support » Plugin: Related Posts Thumbnails Plugin for WordPress » Related on different post_types

  • Hey there,

    So I needed to be able to show related posts in another post type.

    And as this probably could come handy for someone else (or even if you want to add it to your plugin):

    Line #82: added
    $same_post_types = get_option( 'relpoststh_sameposttypes', false);

    Modified the line right after:
    $query = "SELECT distinct ID FROM $wpdb->posts ";

    To be:

    if ($same_post_types) {
    			$extra_where = "";
    		} else {
    			$extra_where = "post_type = '" . $post_type . "' AND ";
    		$where = " WHERE ".$extra_where." post_status = 'publish' AND ID<>" . $id; // not the current post

    inside if ( $validation ) { (line 420ish)
    update_option( 'relpoststh_sameposttypes', $_POST['sameposttypes'] );

    And then a few lines after:
    $sameposttypes = get_option( 'relpoststh_sameposttypes', false );

    At last, added a new TR:

    	<th scope="row"><?php _e( 'Cross-type behaviour', 'related-posts-thumbnails' ); ?>:</th>
    			<input type="checkbox" name="sameposttypes" id="sameposttypes" value="1" <?php if ( $sameposttypes ) echo 'checked="checked"'; ?>/>
    			<label for="sameposttypes"><?php _e( 'Associate posts without considering the post-type', 'related-posts-thumbnails' ); ?></label><br />

    I can give you diff files, or provide more info to anyone who needs this.

    Have fun and a great day!

  • The topic ‘Related on different post_types’ is closed to new replies.