Get Post / Page URL – WordPress

Report
Question

Please briefly explain why you feel this question should be reported .

Report
Cancel

function theme_get_permalink_by_title( $title ) {

// Initialize the permalink value
$permalink = null;

// Try to get the page by the incoming title
$page = get_page_by_title( strtolower( $title ) );

// If the page exists, then let’s get its permalink
if( null != $page ) {
$permalink = get_permalink( $page->ID );
} // end if

return $permalink;

} // end theme_get_permalink_by_title

Use this function by

if( null == theme_get_permalink_by_title( ‘Register For This Site’ ) ) {
// The permalink doesn’t exist, so handle this however you best see fit.
} else {
// The page exists, so do what you need to do.
} // end if/else

0
WordPress 3 months 0 Answer 56 views 0

About Irfan

I love to Develop Websites, Applications and UI Design. I'm a Certified Developer, blogger and owner of Codexjunction.com. My friends call me WordPress Expert too. I like to learn and share technical stuff. For more info quick message me, I'll help you out.

Leave an answer

Captcha Click on image to update the captcha .

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>