Hi@all. Ich habe endlich einen Codeschnipsel gefunden, der mir einen Full-RSS Feed ausgibt. Jetzt hab ich nur ein Problem. Wo kann ich in diesem Code einstellen/einbauen, dass er mir nur die Beiträge der Kategorie 25 ausgibt?
PHP
<?php
###############################################################################################################################
#
# FEEDBUILDER24
# Version 1.3
# (c) 1997 - 2006 by GMB Systems
#
# FILE: XMLRSS.PHP
# DESC: an extensionable feedbuilder for common Wordpress weblogs and entries
# FROM: GMB Systems, < www.grafix-media.de >
# AUTHOR: Sebastian Schwaner, < support@grafix-media.de >
# LICENSE: Pusblished under the terms of the GPL (General Public License)
# You can use this software for commercial and non-commercial projects.
# If changing the source, please send a notice to our developing team.
# DO NOT CHANGE THIS HEAD!
#
# OTHERS: Feel free to add yourself.
#
###############################################################################################################################
# PLEASE CONFIG HERE
###############################################################################################################################
// used language (something like "EN" or "DE" p.ex.)
$RSS_LANGUAGE = "DE";
// additional tags (displayed on the end of every entry in the feed: countercodes, footer-lines and so on)
$RSS_ADDITIONALS = "";
// creating excerpt with length if not 0 [0=NO EXCERPT | > 0 USING EXCERPT]
$RSS_EXCERPT_LENGTH = 0;
// set to true or false to show or hide comment counter [true|false]
$RSS_COMMENT = false;
// set to true if RSS-Users can add entry link to their del.icio.us account as a bookmark [true|false]
$RSS_DEL_ICIO_US = false;
# DO NOT CONFIG BELOW THIS LINE
###############################################################################################################################
require_once("wp-config.php");
// URL to your used mysql-server, p.ex. something like "mysql.host.com"
$MYSQL_SERVER = DB_HOST;
// the username to access the mysql server
$MYSQL_USERNAME = DB_USER;
// your password to the mysql server
$MYSQL_PASSWORD = DB_PASSWORD;
// the name of the used database (not the table)
$MYSQL_DATABASE = DB_NAME;
// the prefix of your Wordpress tables (something like "wp")
$TABLE_PREFIX = $table_prefix;
// prefix + posts to address posts table
$TABLE_POSTS = $TABLE_PREFIX."posts";
// prefix + options to address options table
$TABLE_OPTIONS = $TABLE_PREFIX."options";
// starting the endline of a rss entry
$RSS_STATUS_LINE_ON = "<br><p style=\"border-top:1px solid black;\">";
// ending the endline of a rss entry
$RSS_STATUS_LINE_OFF = "</p>";
# EXECUTE
###############################################################################################################################
$connex = mysql_connect("$MYSQL_SERVER","$MYSQL_USERNAME","$MYSQL_PASSWORD");
mysql_select_db( "$MYSQL_DATABASE",$connex );
$VAR_DATE = date( "D, d M Y G:i:s",time() );
$opt = mysql_fetch_object( mysql_query( "SELECT option_value FROM $TABLE_OPTIONS WHERE option_name = 'siteurl' " ) );
$VAR_SITEURL = $opt->option_value;
$opt = mysql_fetch_object( mysql_query( "SELECT option_value FROM $TABLE_OPTIONS WHERE option_name = 'blogname' " ) );
$VAR_BLOGNAME = $opt->option_value;
$opt = mysql_fetch_object( mysql_query( "SELECT option_value FROM $TABLE_OPTIONS WHERE option_name = 'blogdescription' " ) );
$VAR_DESCRIPTION = $opt->option_value;
$opt = mysql_fetch_object( mysql_query( "SELECT option_value FROM $TABLE_OPTIONS WHERE option_name = 'posts_per_rss' " ) );
if( ! $VAR_POSTS_PER_RSS = $opt->option_value ) $VAR_POSTS_PER_RSS = 10;
$opt = mysql_fetch_object( mysql_query( "SELECT option_value FROM $TABLE_OPTIONS WHERE option_name = 'blog_charset' " ) );
if( ! $VAR_POSTS_CHARSET = $opt->option_value ) $VAR_POSTS_CHARSET = "UTF-8";
$result = mysql_query( "
SELECT post_modified,post_title,guid,post_content,comment_count
FROM $TABLE_POSTS WHERE post_mime_type = ''
ORDER BY ID DESC LIMIT 0,$VAR_POSTS_PER_RSS
" );
mysql_close($connex);
# ---------------------------------------------- OUTPUT RSS/XML - HEAD
echo "<?xml version=\"1.0\" encoding=\"$VAR_POSTS_CHARSET\"?>
<rss version=\"2.0\"
xmlns:content=\"http://purl.org/rss/1.0/modules/content/\"
xmlns:wfw=\"http://wellformedweb.org/CommentAPI/\"
xmlns:dc=\"http://purl.org/dc/elements/1.1/\"
>
<channel>
<title>$VAR_BLOGNAME</title>
<link>$VAR_SITEURL</link>
<description>$VAR_DESCRIPTION</description>
<generator>FeedBuilder24-0.1.0</generator>
<language>$RSS_LANGUAGE</language>
<pubDate>$VAR_DATE</pubDate>
";
# ---------------------------------------------- OUTPUT RSS/XML - BODY
while( $POSTS = mysql_fetch_object( $result ) ) {
// substitute a linefeed \n to a HTML <br> tag
$FORMATTED_TEXT = ereg_replace("\n","<br>",$POSTS->post_content);
$FORMATTED_TEXT = ereg_replace("\r","",$FORMATTED_TEXT);
// if to use excerpt
if( ( $RSS_EXCERPT_LENGTH > 0 ) && ( strlen( $FORMATTED_TEXT ) > $RSS_EXCERPT_LENGTH ) ) {
$OFFSET = strpos( strip_tags( $FORMATTED_TEXT )," ",$RSS_EXCERPT_LENGTH );
$FORMATTED_TEXT = substr( strip_tags( $FORMATTED_TEXT ),0,$OFFSET )." [...]";
}
// calculate a correct date
$opt = explode( " ", $POSTS->post_modified );
$field_date = explode( "-", $opt[0] );
$field_time = explode( ":", $opt[1] );
$FORMATTED_DATE = date( "D, d M Y G:i:s", mktime($field_time[0],$field_time[1],$field_time[2],$field_date[1],$field_date[2],$field_date[0]) );
// Show comment counter
if( $RSS_COMMENT == true ) {
$RSS_COMMENT_COUNT = "» $POSTS->comment_count <a href=\"$POSTS->guid#respond\">Kommentar(e)</a> ";
} else $RSS_COMMENT_COUNT = "";
// Show del.icio.us add-link
if( $RSS_DEL_ICIO_US == true ) {
$RSS_DEL_ICIO_US_ADD = "» Zu del.icio.us <a href=\"http://del.icio.us/post?url=$POSTS->guid&title=$POSTS->post_title\">
hinzufügen</a> ";
} else $RSS_DEL_ICIO_US_ADD = "";
echo "
<item>
<title>$POSTS->post_title</title>
<link>$POSTS->guid</link>
<comments>$POSTS->guid#respond</comments>
<pubDate>$FORMATTED_DATE $formatted_time +0000</pubDate>
<dc:creator>FeedBuilder24-0.1.0</dc:creator>
<category></category>
<guid>$POSTS->guid</guid>
<description><![CDATA[ $FORMATTED_TEXT $RSS_STATUS_LINE_ON $RSS_COMMENT_COUNT $RSS_DEL_ICIO_US_ADD | $RSS_ADDITIONALS $RSS_STATUS_LINE_OFF ]]></description>
</item>
";
}
# ---------------------------------------------- OUTPUT RSS/XML - FOOTER AND ENDING
echo "</channel>
</rss>";
?>
Alles anzeigen