Lấy Get meta title description trong seo yoast như thế nào? wodpress

Thảo luận trong 'Mã nguồn mở Wordpress' bắt đầu bởi seolagi, 11/7/20.

  1. seolagi
    Tham gia ngày:
    16/4/14
    Bài viết:
    1,028
    Đã được thích:
    80
    Điểm thành tích:
    48
    Mình muốn get lấy dữ liệu 2 thẻ meta description và title trong bài viết khi biết ID của bài viết thì làm như thế nào?

    Mình biết cách lấy các tiêu đề, hình ảnh url mặc định hết lun, còn lấy thẻ meta của seo yoast thì không biết làm như thế nào? vì mình muốn nếu không có tiêu đề thì mình sẽ lấy tiêu để SEO yoast hoặc ngược lại ý. Bạn nào biết cách lấy giúp mình với. cảm ơn
    Mã:
        
    $permalink = get_permalink($post->ID);
    $featured_image =  wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'large');
    $featured_image_2 = $featured_image['0'];
    $post_title = rawurlencode(get_the_title($post->ID));
    
    Get meta title description seo yoast
     
    Cảm ơn đã xem bài:

    Lấy Get meta title description trong seo yoast như thế nào? wodpress

  2. admin
    Tham gia ngày:
    22/5/13
    Bài viết:
    4,895
    Đã được thích:
    1,198
    Điểm thành tích:
    113
    Giới tính:
    Nam
    Của bạn đây nhé:
    Mã:
    $post_title = rawurlencode(get_the_title($post->ID));
    $post_title_seo = get_post_meta($post_id, '_yoast_wpseo_title', true);
    $post_des_seo = get_post_meta($post_id, '_yoast_wpseo_metadesc', true);
    if($post_title_seo != '')
    {
        $post_title = $post_title_seo;
    }