Last active
November 1, 2023 12:34
-
-
Save khoipro/eb20734828faee2193553e556d02a27f to your computer and use it in GitHub Desktop.
Get Yoast SEO meta by calling a DB
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function get_yoast_seo_category_meta_title( $object_id) { | |
global $wpdb; | |
$table_name = $wpdb->prefix . 'yoast_indexable'; | |
$result = $wpdb->get_row( $wpdb->prepare("SELECT title FROM $table_name WHERE `object_id` = '%s' AND `object_sub_type` = 'category';", $object_id), ARRAY_A ); | |
return $result['title'] ?? 'None'; | |
} | |
function get_yoast_seo_category_meta_desc( $object_id) { | |
global $wpdb; | |
$table_name = $wpdb->prefix . 'yoast_indexable'; | |
$result = $wpdb->get_row( $wpdb->prepare("SELECT description FROM $table_name WHERE `object_id` = '%s' AND `object_sub_type` = 'category';", $object_id), ARRAY_A ); | |
return $result['description'] ?? 'None'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment