Search
 
SCRIPT & CODE EXAMPLE
 

PHP

wordpress get post slug

<?php
    global $post;
    $post_slug = $post->post_name;
?>
Comment

How to get a WordPress post by slug

function get_post_by_slug($slug){
    $posts = get_posts(array(
            'name' => $slug,
            'posts_per_page' => 1,
            'post_type' => 'product',
            'post_status' => 'publish'
    ));
    
    if(! $posts ) {
        throw new Exception("NoSuchPostBySpecifiedID");
    }

    return $post[0];
}
Comment

PREVIOUS NEXT
Code Example
Php :: how to bulk insert array into sql php 
Php :: Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() 
Php :: php or 
Php :: add 1 day php datetime 
Php :: laravel eloquent select one column 
Php :: how validate array in laravel in request 
Php :: change php version in linux 
Php :: foreach stdclass object php 
Php :: php clone 
Php :: php datum formatieren 
Php :: wp get tagline php 
Php :: require in php 
Php :: php check connection to database 
Php :: use auth automatic login on register 
Php :: eloquent get only some columns 
Php :: php check if value exists in multidimensional array 
Php :: php use variable as object key 
Php :: check variable type in php 
Php :: delete multiple row in laravel 
Php :: migrations required field laravel 
Php :: unset session key 
Php :: upload file in php 
Php :: How do I convert a string to a number in PHP? 
Php :: wordpress change language of specific text php 
Php :: enable gd php 
Php :: laravel auth login with phone or email 
Php :: create function parameters php 
Php :: carbon format date in laravel 
Php :: php call class dynamically 
Php :: laravel online hash password generator 
ADD CONTENT
Topic
Content
Source link
Name
7+3 =