I have not test it but one thing jumps out.
instead of using “$tableposts” on your query use $wpdb->posts like so "SELECT * FROM $wpdb->posts WHERE (post_status = 'publish' OR post_status = 'static') AND post_date <= '$now' AND $name_or_id = '$id'"
Thread Starter
PJ
(@twothirty)
that worked! thank you so much, cheers.
hey twothirty,
could you provide the whole source code of the plugin? because i’d like to use it as well but i cant seem to get it to work 🙁
i already copied the whole code you got above, but it didnt work
thanks a bunch!
Thread Starter
PJ
(@twothirty)
sure thing, here’s the full code:
<?php
/*
Plugin Name: Get-a-Post
Plugin URI: http://guff.szub.net/get-a-post
Description: Display a specific post (or Page) with standard template tags.
Version: R1.1
Author: Kaf Oseo
Author URI: http://szub.net
Copyright (c) 2004, 2005, Kaf Oseo (http://szub.net)
Get-a-Post is released under the GPL license
http://www.gnu.org/licenses/gpl.txt
This is a WordPress plugin (http://wordpress.org).
WordPress is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published
by the Free Software Foundation; either version 2 of the License,
or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
For a copy of the GNU General Public License, write to:
Free Software Foundation, Inc.
59 Temple Place, Suite 330
Boston, MA 02111-1307
USA
You can also view a copy of the HTML version of the GNU General
Public License at http://www.gnu.org/copyleft/gpl.html
*/
function get_a_post($id) {
global $post, $wp_version, $wpdb;
$now = current_time('mysql');
if($id) {
if(is_numeric($id)) {
$name_or_id = 'ID';
} else {
$name_or_id = 'post_name';
}
$post = $wpdb->get_row("SELECT * FROM $wpdb->posts WHERE (post_status = 'publish' OR post_status = 'static') AND post_date <= '$now' AND $name_or_id = '$id'");
get_post_custom($post->ID);
if(preg_match("/^1.2/",$wp_version)) {
start_wp();
} else {
setup_postdata($post);
}
}
}
?>