I'm using a code to make a ratings plugin appear in my custom taxonomy. [code title="functions.php"] if ( $terms ) { foreach ( $terms as $term ) { if ( in_array( $term->name, array( 'Services', 'Book Designing', 'Coaching and Consulting', 'Copywriting', 'Critiquing', 'Editing', 'Freelance Writing', 'Literary Agent', 'Marketing and Promoting', 'Proofreading', 'Publishing' ) ) ) { $found = true; break; }[/code] It should appear in all the categories listed here, but I noticed that instead of "Literary Agents," the plugin developer wrote "Literary Agent," and so the ratings don't show in that category. I simply added an "s" to the end, and I get this error on the front end: Warning: Cannot modify header information - headers already sent by (output started at /home/curveson/public_html/wp-content/themes/template_New_Child_Theme_1/functions.php:1) in /home/curveson/public_html/wp-content/themes/BT/framework/class/class_layout.php on line 152 It doesn't matter what I do in this file. The smallest of changes creates an error. Can someone help me with this? I have no idea how to change Agent to Agents without an error. I'd really appreciate some help. Thanks!
Mark Fail
where is $terms defined?
Anonymous
Here is the full code.
[code title=”#8221;]<?php
// TELL THE CORE THIS IS A CHILD THEME
define(“WLT_CHILDTHEME”, true);
// CHILD THEME LAYOUT SETTINGS
function childtheme_designchanges(){
// LOAD IN CORE STYLES AND UNSET THE LAYOUT ONES SO OUR CHILD THEME DEFAULT OPTIONS CAN WORK
$core_admin_values = get_option(“core_admin_values”);
// SET HEADER
$core_admin_values[“layout_header”] = “2”;
// SET MENU
$core_admin_values[“layout_menu”] = “1”;
// SET RESPONISVE DESIGN
$core_admin_values[“responsive”] = “1”;
// SET COLUMN LAYOUTS
$core_admin_values[“layout_columns”] = array(‘homepage’ => ‘1’, ‘search’ => ‘2’, ‘single’ => ‘2’, ‘page’ => ‘2’, ‘footer’ => ‘3’, ‘2columns’ => ‘0’, ‘style’ => ”, ‘3columns’ => ”);
// SET WELCOME TEXT
$core_admin_values[“header_welcometext”] = “Your own text could go here!”;
// SET RATING
$core_admin_values[“rating”] = “1”;
$core_admin_values[“rating_type”] = “1”;
// BREADCRUMBS
$core_admin_values[“breadcrumbs_inner”] = “1”;
$core_admin_values[“breadcrumbs_home”] = “0”;
// TURN OFF CATEGORY DESCRIPTION
$core_admin_values[“category_descrition”] = “0”;
// GEO LOCATION
$core_admin_values[“geolocation”] = “”;
$core_admin_values[“geolocation_flag”] = “AF”;
// FOOTER SOCIAL ICONS
$core_admin_values[“social”] = array(
‘twitter’ => ‘##’, ‘twitter_icon’ => ‘fa-twitter’,
‘facebook’ => ‘##’, ‘facebook_icon’ => ‘fa-facebook’,
‘dribbble’ => ”, ‘dribbble_icon’ => ‘fa-google-plus’,
‘linkedin’ => ‘##’, ‘linkedin_icon’ => ‘fa-linkedin’,
‘youtube’ => ‘##’, ‘youtube_icon’ => ‘fa-youtube’,
‘rss’ => ‘##’, ‘rss_icon’ => ‘fa-rss’,
);
// FOOTER COPYRIGHT TEXT
$core_admin_values[“copyright”] = “© Copyright 2015 Creative Lingua”;
// HOME PAGE OBJECT SETUP
$core_admin_values[“homepage”][“widgetblock1”] = “basicsearch_0,text_1,tabs_3,text_4,”;
$core_admin_values[‘widgetobject’][‘basicsearch’][‘0’] = array(
‘col1’ => “<h1 style=\”text-align: center;\”>We\’re making the writing world a lot smaller…</h1>”,
‘col2’ => “<h2 style=\”text-align: center;\”>… And it\’s free to join!</h2>”,
‘fullw’ => “no”,
);
$core_admin_values[‘widgetobject’][‘text’][‘1’] = array(
‘text’ => ““,
‘autop’ => “1”,
‘fullw’ => “no”,
);
$core_admin_values[‘widgetobject’][‘tabs’][‘3’] = array(
‘title1’ => “Featured Listings”,
‘query1’ => “meta_key=featured&meta_value=yes”,
‘content1’ => “”,
‘style1’ => “list”,
‘title2’ => “Recent Listings”,
‘query2’ => “orderby=IDorder=desc”,
‘content2’ => “”,
‘style2’ => “list”,
‘title3’ => “”,
‘query3’ => “”,
‘content3’ => “”,
‘style3’ => “grid”,
‘title4’ => “”,
‘query4’ => “”,
‘content4’ => “”,
‘style4’ => “grid”,
‘btnview’ => “yes”,
‘perrow’ => “3”,
‘fullw’ => “no”,
);
$core_admin_values[‘widgetobject’][‘text’][‘4’] = array(
‘text’ => “[su_button url=\”\” style=\”3d\” background=\”#ccbd0c\” size=\”7\” center=\”yes\” radius=\”round\”]Add a listing[/su_button]”,
‘autop’ => “1”,
‘fullw’ => “no”,
);
// SET ITEMCODE
$core_admin_values[“itemcode”] = “[IMAGE hover=1 hover_content=5] [RATING]<div class=’caption’><h1>[TITLE]</h1><div class=’hidden_details’>[ICON id=’fa fa-group’ fa=1] [hits] user views [ICON id=’fa fa-comments’ fa=1] [COMMENT_COUNT] reviews <hr />[EXCERPT size=200] <div class=’clearfix’></div><hr />[BUTTON] <span class=’right hidden-xs hidden-sm’ style=’padding-right:20px; line-height:40px;’>[FAVS]</span>[ICON id=’fa fa-tags’ fa=true] [CATEGORY] [TAGS] [DISTANCE]</div></div>”;
// SET LISTING PAGE CODE
$core_admin_values[“listingcode”] = “<div class=’block’><div class=’block-title’><h1><span>[TITLE]</span></h1></div><div class=’block-content’> [IMAGES] <span class=’right’ style=’margin-top:7px; margin-right:20px;’>[CONTACT button=1] </span><ul class=’nav nav-tabs navstyle1′ id=’Tabs’> <li class=’active’>{Description} {Details}<div class=’tab-content’><div class=’tab-pane active’ id=’t1′>[TOOLBOX]<h5>[TITLE]</h5>[CONTENT] [GOOGLEMAP] </div><div class=’tab-pane’ id=’t2′>[FIELDS hide=’map’]</div></div></div></div> [COMMENTS box=1]”;
// SET PRINT PAGE CODE
$core_admin_values[“printcode”] = “<div class=’center’> <p id=’postTitle’>[TITLE-NOLINK]</p> <p id=’postMeta’>Date:[DATE] </p> <p id=’postLink’>[LINK]</p> <div id=’postContent’>[CONTENT]</div> <div id=’postFields’>[FIELDS]</div> <p id=’printNow’>Print</p> </div>”;
// RETURN VALUES
return $core_admin_values;
}
// FUNCTION EXECUTED WHEN THE THEME IS CHANGED
function _after_switch_theme(){
// SAVE VALUES
update_option(“core_admin_values”,childtheme_designchanges());
}
add_action(“after_switch_theme”,”_after_switch_theme”);
// DEMO MODE
if(defined(“WLT_DEMOMODE”)){
$GLOBALS[“CORE_THEME”] = childtheme_designchanges();
}
/**
* Sets taxonomy terms that are allowed to do auto placement
*
* @param boolean $can_apply_filter
* @param string $filter_name
* @param string $value
* @param int $post_id
* @return $can_apply_filter
*/
function mrp_check_post_tag_auto_placement( $can_apply_filter, $filter_name, $value, $post_id ) {
if ( $can_apply_filter ) {
$found = false;
$terms = get_the_terms( $post_id, ‘listing’ ); // << add your taxonomy here in her
if ( $terms ) {
foreach ( $terms as $term ) {
if ( in_array( $term->name, array( ‘Services’, ‘Book Designing’, ‘Coaching and Consulting’,
‘Copywriting’, ‘Critiquing’, ‘Editing’, ‘Freelance Writing’, ‘Literary Agent’,
‘Marketing and Promoting’, ‘Proofreading’, ‘Publishing’ ) ) ) {
$found = true;
break;
}
}
}
if ( ! $found ) {
$can_apply_filter = false;
}
}
return $can_apply_filter;
}
add_filter( ‘mrp_can_apply_filter’, ‘mrp_check_post_tag_auto_placement’, 10, 4 );
/**
* Sets post_tag taxonomy terms that are allowed to do wp comment integration
*
* @param boolean $can_apply_filter
* @param string $filter_name
* @param string $value
* @param int $post_id
* @return $can_apply_filter
*/
function mrp_check_post_tag_wp_comment_integration( $can_apply_wp_comment_integration, $post_id, $type ) {
if ( $can_apply_wp_comment_integration ) {
$found = false;
$terms = get_the_terms( $post_id, ‘listing’ ); // << add your taxonomy here in her
if ( $terms ) {
foreach ( $terms as $term ) {
if ( in_array( $term->name, array( ‘Services’, ‘Book Designing’, ‘Coaching and Consulting’,
‘Copywriting’, ‘Critiquing’, ‘Editing’, ‘Freelance Writing’, ‘Literary Agent’,
‘Marketing and Promoting’, ‘Proofreading’, ‘Publishing’ ) ) ) {
$found = true;
break;
}
}
}
if ( ! $found ) {
$can_apply_wp_comment_integration = false;
}
}
return $can_apply_wp_comment_integration;
}
add_filter( ‘mrp_can_apply_wp_comment_integration’, ‘mrp_check_post_tag_wp_comment_integration’, 10, 3 );
/**
* Filters the_content() to perform auto placement of the rating results before the post content
*
* @param $content
* @return filtered content
*/
function mrp_rating_results_auto_placement_before_content( $content ) {
// get the post id
global $post;
$post_id = null;
if ( ! isset( $post_id ) && isset( $post ) ) {
$post_id = $post->ID;
} else if ( ! isset($post) && ! isset( $post_id ) ) {
return; // No post id available to display rating form
}
$can_apply_filter = ! ( ! in_the_loop() || ( is_admin() && ( ! defined( ‘DOING_AJAX’ ) || ! DOING_AJAX ) ) );
if ( ! apply_filters( ‘mrp_can_apply_filter’, $can_apply_filter, ‘the_content’, $content, $post_id ) ) {
return $content;
}
$rating_form_id = MRP_Utils::get_rating_form( $post->ID );
$rating_result = MRP_Multi_Rating_API::display_rating_result( array(
‘rating_form_id’ => $rating_form_id,
‘post_id’ => $post_id,
‘echo’ => false,
‘show_date’ => false,
‘show_rich_snippets’ => $position_settings[MRP_Multi_Rating::GENERATE_RICH_SNIPPETS_OPTION],
‘class’ => $rating_results_position . ‘ mrp-filter’
) );
$filtered_content = __( ‘<b>Overall Rating:</b> ‘, ‘my-text-domain’); // << You can add text as a prefix here
if ( $rating_result != null ) {
$filtered_content .= $rating_result;
} else {
$filtered_content .= __( ‘No ratings yet’, ‘my-text-domain’);
}
$filtered_content .= $content;
return $filtered_content;
}
add_filter( ‘the_content’, ‘mrp_rating_results_auto_placement_before_content’ );
?> [/code]
This is a custom code he added to my functions because the ratings plugin wasn’t working with PremiumPress. This code works perfectly fine until I add any little change to this file. It doesn’t matter what I put in , I get an error regardless.
Mark Fail
can u zip and attach the file so i can see it.
Anonymous
I understand that you mean the functions file?
Anonymous
Had a company clean some malware off my server and is working again.
Josh
Thanks for sharing 🙂