Hi,
ich hab mir das Frontpage Filter Plugin geholt weil ich nur ein paar Kategorien auf der Startseite anzeigen möchte.
stimmt der quelltext denn?!?
PHP
<?php
/*
Plugin Name: Front Page Filter
Plugin URI: http://smallestbusiness.com/category/wordpress
Description: A plugin that filters categories for the main page.
Author: Ami Heines
Version: 0.9
Author URI: http://smallestbusiness.com
*/
/* Copyright 2006 Ami Heines (email form : http://smallestbusiness.com/about)
This program 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.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
?>
<?php
add_option('sb_front_page_filter', '= 1', 'filter posts by category. example:"=1" to show only posts from category 1\n another example: "!=2"', 'yes');
function sb_filter_add_option_page() {
if (function_exists('add_options_page')) {
add_options_page('Front Page Filter', 'Front Page Filter', 9, basename(__FILE__), 'sb_fpf_options_subpanel');
}
}
function sb_fpf_options_subpanel() {
if($_POST['sb_fpf_save']){
update_option('sb_front_page_filter',$_POST['sb_front_page_filter']);
echo '<div class="updated"><p>Front Page Category Filter saved successfully.</p></div>';
}
?>
<div class="wrap">
<h2>Front Page Category Filter Options</h2>
<form method="post" id="sb_fpf_options">
<fieldset class="options">
<legend>Category Filter for Main Page</legend>
<table width="100%" cellspacing="2" cellpadding="5" class="editform">
<tr valign="top">
<th width="33%" scope="row">Filter:</th>
<td><input name="sb_front_page_filter" type="text" id="sb_front_page_filter"
value="<?php echo get_option('sb_front_page_filter') ;?>" size="30" maxlength="80" />
<br />Sets the category filter for the main page of the website.
</td>
</tr>
</table>
<h2>Help</h2>
If you need help, go to the <a href="http://smallestbusiness.com/category/wordpress">suport area</a> for this plugin.
<p class="submit"><input type="submit" name="sb_fpf_save" value="Save" /></p>
</fieldset>
</form>
</div>
<?php
}
function sb_filter_category_where($where) {
if (is_home()) {
$where .= " AND category_id " . get_option('sb_front_page_filter');
}
return $where;
}
function sb_filter_category_join($join) {
global $table_prefix;
//echo $table_prefix;
if (is_home()) {
$join .= " LEFT JOIN ".$table_prefix."post2cat ON (".$table_prefix."posts.ID = ".$table_prefix."post2cat.post_id)";
}
return $join;
}
add_filter('posts_where', 'sb_filter_category_where');
add_filter('posts_join' , 'sb_filter_category_join');
add_action('admin_menu' , 'sb_filter_add_option_page');
?>
Alles anzeigen
weil ich nach aktivierung den fehler hier kriege:
Code
[B]WordPress database error:[/B] [Not unique table/alias: 'wp_post2cat']
SELECT DISTINCT * FROM wp_posts LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) LEFT JOIN wp_post2cat ON (wp_posts.ID = wp_post2cat.post_id) WHERE 1=1 AND (category_id != 1) AND post_date_gmt <= '2007-01-19 22:22:59' AND (post_status = "publish" OR post_author = 1 AND post_status != 'draft' AND post_status != 'static') AND post_status != "attachment" AND category_id = 1 GROUP BY wp_posts.ID ORDER BY post_date DESC LIMIT 0, 10
danke schonmal im voraus
bye
Tobi