Comment obtenir l'identifiant de Page si je connais le titre uniquement?
-
30-10-2019 - |
Question
Y a-t-il un funciton opposé exact à celui-ci:
get_the_title(ID)
Je sais qu'il y a:
get_the_id()
Mais cela ne semble accepter aucun argument.
Donc, en gros, je cherche quelque chose comme:
$title = 'Something';
get_the_id($title);
Je connais déjà cette solution:
global $wpdb;
$post_name = get_query_var('name');
$post_id = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = $post_name");
Mais peut-être qu'il me manque quelque chose de buts?
Pas de solution correcte
Licencié sous: CC-BY-SA avec attribution
Non affilié à wordpress.stackexchange