最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

title - Special characters in post_title replaced by '?'

programmeradmin7浏览0评论

This is my code :

if( !empty( $_POST ) && !empty( $_POST['foo-action'] ) ){
    $html .= sprintf( '<table><thead><tr><th>%1$s</th><th>%2$s</th><th>%3$s</th></tr></thead><tbody>',
       'Post title',
       'pdf to import',
       'imported'
    );
    if( $_POST['foo-action'] === "newsletters" ){
        $category = get_category_by_slug( 'newsletters' );
        $atts = [
            'category' => $category->term_id,
            'posts_per_page' => -1,
            'order' => 'ASC'
        ];
        $newsletter_posts = get_posts( $atts );

        foreach ( $newsletter_posts as $newsletter_post ){
            $post_meta_data = get_post_meta( $newsletter_post->ID );
            $pdf = get_post( $post_meta_data['pdf'][0] );
            $html .= sprintf( '<tr><td>%1$s</td><td>%2$s</td><td>%3$s</td></tr>',
                $newsletter_post->post_title,
                $pdf->guid,
                'true'
            );
        }
    }
    $html .= sprintf( '</tbody></table>');
}

When the post title contains special characters like :

Foo n° 46 — 21 05 2014

The output displayed with $newsletter_post->post_title is :

Foo n° 46 ? 21 05 2014

How can I fixe this ?

发布评论

评论列表(0)

  1. 暂无评论