Search
 
SCRIPT & CODE EXAMPLE
 

PHP

convert post name to id

//You can use OBJECT or null <-null worked for me
/*
* RETURNS: the post array 
* post_name: is the name of the post you are looking for
* OBJECT: accepts results of WP_posts or get_posts  (i.e. $posts)
*         if you don't have and OBJECT just use null instead
* post_type: the name of your post type (i.e. 'page' or 'post'
* additional information https://developer.wordpress.org/reference/functions/get_page_by_title/
*
* ALSO get_page_by_path ('slug', OBJECT, 'post_type')
*/

$post = get_page_by_title( 'post_name' , OBJECT, 'post_type' );
echo $post->ID;

Comment

PREVIOUS NEXT
Code Example
Php :: how to display array of img in wordpress 
Php :: mac install multiple php versions 
Php :: laravel remove public from url on shared host 
Php :: laravel vue csrf 
Php :: wp_query post by category id 
Php :: how to use required_with in laravel to array element 
Php :: php search in array case insensitive 
Php :: laravel collection each 
Php :: wordpress throw to debug.log 
Php :: Your Composer dependencies require the following PHP extensions to be installed: curl 
Php :: strlen php 
Php :: get user avatar wordpress 
Php :: disable block editor on widget section wordpress 
Php :: check if all values in array are equal php 
Php :: adding column to array php 
Php :: PHP | get client ip 
Php :: Allowed memory size of 1610612736 bytes exhausted (tried to allocate 67108872 bytes) in phar:///usr/local/bin/composer1.phar/src/Composer/DependencyResolver/RuleSet.php on line 8 
Php :: php remove object from array by property 
Php :: laravel db::query update 
Php :: in loop how add string by comma in php 
Php :: Install the php_mysql extensions 
Php :: using laravel back function on blade 
Php :: join cakphp 
Php :: show query in laravel 
Php :: how to install multiple php versions ubuntu 
Php :: get order details by id woocommerce 
Php :: pdo bindparam string 
Php :: Auth log out laravel 
Php :: remove action from theme wordpress 
Php :: check if the form is submitted php 
ADD CONTENT
Topic
Content
Source link
Name
2+8 =