admin管理员组

文章数量:1323714

i am adding a option to a plugin. I want to add a Subfix after the curent test variable is return from a summarizer.

So my data is in excerpt variable and i want to add text that is in this variable $summarizer_add_html_trust_bulletpoints.

How can i do that?

function create_excerpt_product($post_ID)  {
    global $wpdb;

    $excerpt = $wpdb->get_var("SELECT post_excerpt FROM $wpdb->posts WHERE ID = $post_ID");
    if(!$excerpt && !$force_rewrite_excerpt) {        
        require_once('config.php');
        
        // load the correct Document class for the language specified
        require_once("lib/$lang/$document[$lang].php");

        $content = $wpdb->get_var("SELECT post_content FROM $wpdb->posts WHERE ID = $post_ID"); 
        $title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $post_ID");        
        
        $doc = new $document[$lang]($title, $content);
        
        // TODO add tags, category and others to the query
        $summarizer_add_html_trust_bulletpoints='my demo text' ;

        $excerpt = $doc->getSummary($summary_options);
        //$excerpt = $excerpt + $summarizer_add_html_trust_bulletpoints ;
        $excerpt = esc_sql($excerpt);
        
            $wpdb->query("UPDATE $wpdb->posts SET post_excerpt = '$excerpt' WHERE ID = $post_ID");
        
    }
}

?>

i am adding a option to a plugin. I want to add a Subfix after the curent test variable is return from a summarizer.

So my data is in excerpt variable and i want to add text that is in this variable $summarizer_add_html_trust_bulletpoints.

How can i do that?

function create_excerpt_product($post_ID)  {
    global $wpdb;

    $excerpt = $wpdb->get_var("SELECT post_excerpt FROM $wpdb->posts WHERE ID = $post_ID");
    if(!$excerpt && !$force_rewrite_excerpt) {        
        require_once('config.php');
        
        // load the correct Document class for the language specified
        require_once("lib/$lang/$document[$lang].php");

        $content = $wpdb->get_var("SELECT post_content FROM $wpdb->posts WHERE ID = $post_ID"); 
        $title = $wpdb->get_var("SELECT post_title FROM $wpdb->posts WHERE ID = $post_ID");        
        
        $doc = new $document[$lang]($title, $content);
        
        // TODO add tags, category and others to the query
        $summarizer_add_html_trust_bulletpoints='my demo text' ;

        $excerpt = $doc->getSummary($summary_options);
        //$excerpt = $excerpt + $summarizer_add_html_trust_bulletpoints ;
        $excerpt = esc_sql($excerpt);
        
            $wpdb->query("UPDATE $wpdb->posts SET post_excerpt = '$excerpt' WHERE ID = $post_ID");
        
    }
}

?>
Share Improve this question asked Sep 9, 2020 at 16:57 Pierre Pierre 1
Add a comment  | 

1 Answer 1

Reset to default 1

You've commented out the line that does this:

//$excerpt = $excerpt + $summarizer_add_html_trust_bulletpoints ;

The only mistake is that you've used + instead of ., which is the correct concatenation operator in PHP.

$excerpt = $excerpt . $summarizer_add_html_trust_bulletpoints;

本文标签: pluginsAdd text to variable