Posts tagged: programming

wp_list_pages errors WordPress 2.5 and 2.6

By Lewis Wolfe, Thursday, July 31st, 2008

In the course of producing a theme that uses wp_list_pages for the standard menu, with a whole list of args, including exclude, as documented here, I find a series of non-standard behaviours - particularly when using a .mo file in the theme directory and in /wp-content/languages/

This is only with wp_list_pages for 2.5 upwards, WordPress 2.3 versions, not a problem, doing exactly what it’s supposed to…

The “official” radar seems to have no interest in the matter, so I was wondering whether any one could report their experiences…?

WordPress as CMS and PHP

By Lewis Wolfe, Wednesday, July 9th, 2008

If you’re using WordPress as a CMS and doing some extra coding - for example picking something from an extra db table to display on a certain page, eg page_id=4

$pageVar = $wpdb->get_var(SELECT var FROM my_table WHERE something=’something_else’);

and then you also want to SEO the <title> a little, so in header.php you put:-

<?php if (is_page(’4′)) $extraTitle = ‘ยป ‘ . $pageVar; ?>

<title><?php bloginfo(’name’); ?> <?php wp_title(); ?> <?php echo $extraTitle; ?></title>

It won’t work - $pageVar doesn’t have global scope, because of the method used to get the header on the page.

<?php get_header(); ?>

Instead, one way round this is to use:

<?php include(TEMPLATEPATH . ‘/header.php’); ?>

and it will work
This has the nature of a hack - use sparingly and probably not in themes for general release. And stay away from $_GLOBALS