I am trying to have 2 php functions automatically inserted in every post for my CPT. The problem I am having is that even though I've found a way to add text, Im not sure how to add the php functions cause with the code I have it adds it as regular text to the post.
This is what I have in my functions file ---
add_filter( 'default_content', 'my_editor_content', 10, 2 );
function my_editor_content( $content, $post ) {
switch( $post->post_type ) {
case 'property':
$content = "<div>";
$content . "<?php if ( class_exists( 'MRP_Multi_Rating_API' ) ) {
MRP_Multi_Rating_API::display_rating_result( array(
'rating_item_ids' => 2,
'show_count' => false,
'result_type' => 'value_rt',
'no_rating_results_text' => 'Not Rated'
) ); } ?><?php if ( class_exists( 'MRP_Multi_Rating_API' ) ) {
MRP_Multi_Rating_API::display_rating_result( array(
'rating_item_ids' => 5,
'show_count' => false,
'result_type' => 'overall_rt',
'no_rating_results_text' => 'Not Rated'
) );
} ?>";
$content = "</div>";
break;
default:
$content = "your default content";
break;
}
return $content;
}
How can I fix this so my functions work and is it possible to make it add to every post not just the new ones created?
Thanks