Archive

Archive for January, 2010

Como obter o ID de um post dentro e fora do Loop do WordPress

January 16th, 2010 lmmendes No comments

Ultimamente tenho andado a fazer algumas modificações ao meu blog e surgiu-me a necessidade de obter o ID de um post fora do loop (The Loop) do WordPress:

<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>

Dentro do loop para obter o ID basta fazer o seguinte:

$post->ID

Já fora do loop para termos acesso ao ID do post vamos ter que aceder á variável global $wp_query, ou seja, para obtermos acesso ao ID do post:

global $wp_query;
$wp_query->post->ID

É tão simples como isso, para saberem mais informação sobre o $wp_query consultem o Codex aqui.

Categories: Development, WordPress Tags: ,

Remove WordPress iNove theme sidebar using custom fields

January 16th, 2010 lmmendes 8 comments

I’m using WordPress iNove theme v.1.4.6 and i needed a way to hide the sidebar for a specific post so i dove in the iNove theme code and figured out how to do this with the minimum changes to the original theme code.

First open the iNove theme ‘header.php’ file using your favorite editor, usually found at <wp install folder>/wp-content/themes/inove/header.php.

Now look for this piece of code (starting from the top of the file):

... some code ...
			$feed = 'http://' . $options['feed_url'];
		}
	} else {
		$feed = get_bloginfo('rss2_url');
	}
?>

Read more…