WordPress: get page link by ID

This function is used to get the_permalink() of a certain page using it’s ID (outside the loop). To use it within a theme, just:

<?php getPageLink(ID); ?>
function getPageLink($pageId){
   if(!is_numeric($pageId)) {
      return;
   }
   global $wpdb;
   $sql_query = 'SELECT DISTINCT * FROM ' . $wpdb->posts . ' WHERE ' . $wpdb->posts . '.ID=' . $pageId;
   $posts = $wpdb->get_results($sql_query);
   if(!empty($posts)) {
      foreach($posts as $post) {
         return nl2br($post->guid);
      }
   }
}

WordPress: Get Page Title by ID

This function is used to get the title(); of a certain page using it’s ID (outside the loop). To use it within a theme, just:

<?php getPageTitle(ID); ?>
function getPageTitle($pageId){
	if(!is_numeric($pageId)) {
		return;
	}
	global $wpdb;
	$sql_query = 'SELECT DISTINCT * FROM ' . $wpdb->posts . ' WHERE ' . $wpdb->posts . '.ID=' . $pageId;
	$posts = $wpdb->get_results($sql_query);
	if(!empty($posts)) {
		foreach($posts as $post) {
			return nl2br($post->post_title);
		}
	}
}

My new home: WebCard

October is a catastrophic month for me (financially): I must pay the server and a lot of my domains… and 2 months before Xmas I have to pay a sustancial ammount on my creditcard… anyway, this year I’ve added a new domain: jorgeepunan.info. It was only US$1 and I wanted for long time to do a website on my own and for me as a personal card… so this webcard represents the way that anyone can contacts me for anything, and it shows what I’ve done as a professional.

I’m always open for feedback, and hope you enjoy the experience.

http://www.jorgeepunan.info

Jorge Epuñan WebCard

Cita 8

Cuando estoy trabajando en un problema nunca pienso sobre su belleza, técnicamente pienso en cómo resolverlo. Pero cuando he terminado, si la solución no es bella, sé que está equivocada.

Richard Buckminster Fuller