2017-02-17 9 views
0

このタイトルクエリは機能しません。ポストタイトルにはタイトルの前に特殊文字が付きます。私は彼のタイトルを確認します。たとえば:WordPressのポストタイトルクエリが特殊文字で機能していません

-Y-ここでのコードのポストシングルページテンプレートは、次のとおりです。

<?php 

$get_s_value = $_GET['search']; 

if ($get_s_value == 'true') { 

    $current_p_title = get_the_title(); 

    $args = array (
     'post_type' => 'trending', 
     'post_status' => 'publish', 
     "s"   => $current_p_title, 
    ); 

    query_posts($args); 

    if (have_posts()): the_post(); 

     $sahifa_trending_count = get_post_meta(get_the_ID(), '_trending_count', 1); 
     $update_count   = $sahifa_trending_count + 1; 
     $last_m_date   = get_the_modified_date('Y-m-d'); 
     $trending_c_date  = date('Y-m-d'); 

     if ($last_m_date = $trending_c_date) { 

      update_metadata('post', get_the_ID(), '_trending_count', $update_count); 
     } else { 
      update_metadata('post', get_the_ID(), '_trending_count', '1'); 
     } 

    else: 

     $create_post = array (
      'post_type' => 'trending', 
      'post_title' => get_the_title(), 
      'post_status' => 'publish', 
      'meta_input' => array (
       '_trending_count' => '1', 
      ), 
     ); 

     wp_insert_post($create_post); 


    endif; 
    wp_reset_query(); 
} 

答えて

0

タイトルをコードしてみてください。

$create_post = array (
      'post_type' => 'trending', 
      'post_title' => utf8_encode(get_the_title()), 
      'post_status' => 'publish', 
      'meta_input' => array (
       '_trending_count' => '1', 
      ), 
     ); 
関連する問題