I tried as written in the thread suggested and modified the plugin to include the SQL query
function sample_function() {
global $post;
$id = $post->ID;
$town = get_post_meta($id, 'test', true);
if ($town != '') {
echo $town;}
}
but it does not work at all.
This is the first plugin I am writing and I seem to be missing some vital part.
<?php
/*
Description: Posts the town to the meta title
*/
if (!class_exists("ThriftyPlugin")) {
class ThriftyPlugin {
function ThriftyPlugin() { //constructor
}
function addHeaderCode() {
?>
<!-- Some test comment in the DOM -->
<?php
}
function addContent($content = '') {
$content .= "Some test content at end post
";
return $content;
}
function authorUpperCase($author = '') {
return strtoupper($author);
}
function sample_function() {
global $post;
$id = $post->ID;
$town = get_post_meta($id, 'test', true);
if ($town != '') {
echo $town;}
}
}
} //End Class ThriftyPlugin
if (class_exists("ThriftyPlugin")) {
$dl_PostToTitle = new ThriftyPlugin();
}
//Actions and Filters
if (isset($dl_PostToTitle)) {
//Actions
add_action('wp_head', array(&$dl_PostToTitle, 'addHeaderCode'), 1);
//Filters
add_filter('the_content', array(&$dl_PostToTitle, 'addContent'));
add_filter('get_comment_author', array(&$dl_PostToTitle, 'authorUpperCase'));
}
?>
I have no idea how to hook the sample_function to make it work. I then need to make the content written within the <title></title> tags, but I’ll discover that later.
Any help on how to get the content echoed?