Wednesday, 1 July 2015

Get Post Title or Post Permalink using Post Name in Wordpress


You can get post title and permalink any one you want from post it easy to get this.

I have one example post that can be useful that.

you can also also use in search. and simple any where in wordpress.

Simple Get Wordpress.

$city_name = array("Bab Ezzouar","Babol","Babruysk","Bago City");

foreach($city_name as $city){
 echo $city;
$posts = get_posts(array('name' => $city, 'post_type' => 'your-postname-here','post_status'=>'publish'));

foreach ($posts as $post) {
  echo $title = get_the_title($post->ID);
  echo    $permalink = get_permalink($post->ID);

    break; //use this to limit to a single result

check out your wordpress. cityname enter your post name and post type check out result

No comments:

Post a Comment

Thank You For Comment