Skip to content

Instantly share code, notes, and snippets.

@danielpowney
Last active August 29, 2015 14:23
Show Gist options
  • Save danielpowney/01fe76ae76baab472d78 to your computer and use it in GitHub Desktop.
Save danielpowney/01fe76ae76baab472d78 to your computer and use it in GitHub Desktop.
Changes the default rating form so that it's set based on post type. This overrides the general settings but keeps rating form chosen from post meta if set.
<?php
/**
* Sets default rating form for a post based on post type
*
* @param int $rating_form_id
* @param int $post_id
* @param array $params
* @return $rating_form_id
*/
function mrp_default_rating_form_by_post_type( $rating_form_id, $post_id, $params ) {
if ( $post_id ) {
$post_type = get_post_type( $post_id );
switch ( $post_type ) {
case 'post' :
$rating_form_id = 1;
break;
case 'page' :
$rating_form_id = 2;
break;
}
}
return $rating_form_id;
}
add_filter( 'mrp_default_rating_form', 'mrp_default_rating_form_by_post_type', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment