Archives | Contacts | Politique de confidentialité
21 mars 2007
Nerd 2.0

Archive pour Wordpress! Sans liens?

Quand je suis surfé aujourd'hui défaut sur mon blog, j'ai soudainement découvert que plus aucun lien seront affichés dans les archives du blog. Bien que les étiquettes toujours regardé comme des liens, mais n'a pas eu le contenu:

<a href="">Postname</a>

Nun hab ich mich auf die Suche gemacht und siehe da, es gibt eine neue Version des Plugins.

Natürlich habe gleich das Plugin aktualisiert. Was passiert? Natürlich nix!

Nachdem ich also nun etwas im Code und den Kommentaren auf der Seite geschnüffelt habe. Finde dich dann dieses Kommentar, welches frei soviel aussagt, dass man einfach die letzte Zeile der Funktion kg_archives() von “ return $koutput1 ;” in “ echo $koutput1; ” ändern muss.

Diesmal funktioniert auch alles.

Endlich ein wieder ein funktionierendes Archiv!

Komplette Veränderung und deutsch Datei…


Für alle die aus den Codeänderungen nicht so recht schlau geworden sind, hier nochmal die komplette Datei.
/*
Plugin Name: KG Archives
Plugin URI: http://katesgasis.com/2005/05/01/kg-archives-plugin/
Description: Yet another sortable archives from <a href="http://www.katesgasis.com">katesgasis.com</a>.
Version: 3.0
Author: Kates Gasis
Author URI: http://www.katesgasis.com
*/
/* Change this to the slug of your desired page */
$archive_page_slug = "archives";
function kgsortarch_embed_callback( $content )
{
if(! is_page($archive_page_slug)){
return $content;
}
return preg_replace_callback("|
\s*<kgarchives ((\w+)="[\" +(\w+)="[\">\s*</kgarchives>
|", 'kgsortarch_handler', $content);
}
add_filter('the_content', 'kgsortarch_embed_callback');
function kgsortarch_handler( $matches )
{
$categorized = false;
$initialmonth = "all";
$excludecat = "";
$size = preg_match_all("| +(\w+)=[\"']?([^\"'/]+)[\"' ]?|", $matches[0], $attributes);
for( $i = 0; $i &lt;= $size; $i++ )
{
$name = $attributes[1][$i];
$value = $attributes[2][$i];
if( strlen($name) &lt; 1 ) continue;
switch( strtolower($name) )
{
case "initialmonth": $initialmonth = $value; break;
case "excludecat": $excludecat = $value; break;
case "categorized":	$categorized = $value; break;
}
}
$excludecats = preg_split("/[\s,]+/", $excludecat);
return kg_archives($categorized,$initialmonth,$excludecats);
}
function fetchArchives($type,$archmonth,$excludecats) {
global $month, $wpdb;
$categorized = false;
if(strtolower($type)== "true") {
$categorized = true;
}
$rewritecode = array(
'%year%',
'%monthnum%',
'%day%',
'%hour%',
'%minute%',
'%second%',
'%postname%',
'%post_id%',
'%category%',
'%author%',
'%pagename%'
);
$permalink = get_settings('permalink_structure');
$koutput2="";
$now = current_time('mysql');
$klatestmonth = kgmonthslist('limit 1');
$kdefaultmonth  = mysql2date('Y-m-',$klatestmonth[0]-&gt;post_date);
$ktables = "$wpdb-&gt;posts, $wpdb-&gt;post2cat, $wpdb-&gt;categories ";
$kwhere = "AND post_date LIKE '$kdefaultmonth%' ";
$korderby = " year DESC, month DESC, post_date DESC";
if(strtolower($archmonth) == "all"){
$kwhere = "";
} else {
$kwhere = "AND post_date LIKE '$archmonth%' ";
}
if(!empty($excludecats)&amp;&amp;isset($excludecats)){
foreach($excludecats as $excludecat) {
$kwhere .= "AND category_nicename != '" . $excludecat . "' ";
}
}
$kwhere .= "AND category_id = cat_ID AND post_id = ID ";
if($categorized){
$korderby = " year DESC, month DESC, cat_name ASC, post_date DESC ";
$kquery = "SELECT ID, YEAR(post_date) AS year, MONTH(post_date) as month, post_name, post_date, post_title, comment_status, category_id, cat_name, post_author, cat_ID, post_id FROM " . $ktables . " WHERE post_type != 'page' AND post_status='publish' AND post_password='' AND post_date &lt; '" . $now . "' " . $kwhere . " ORDER BY " . $korderby;
} else {
$kquery = "SELECT DISTINCT(ID) , YEAR(post_date) AS year, MONTH(post_date) as month, post_name, post_date, post_title, comment_status, post_author FROM " . $ktables . " WHERE post_type != 'page' AND post_status='publish' AND post_password='' AND post_date &lt; '" . $now . "' " . $kwhere . " ORDER BY " . $korderby;
}
$arcresults2 = $wpdb-&gt;get_results($kquery);
$koutput2 .= "
<p class="\">\n";	$kcurrmonth = "";
$kcurrcat = 0;
if($arcresults2){
$kisinlist = false;
foreach($arcresults2 as $arcresult2){
$kpostmonth = zeroise($arcresult2-&gt;month,2);
$kpostyear = $arcresult2-&gt;year;
$kmonth = $kpostmonth . $kpostyear;
if($kcurrmonth != $kmonth){
if ($kisinlist) {
$koutput2 .= "
\n";
if($categorized) {
$kcurrcat = "";
}
$kisinlist = false;
}
$kcurrmonth = $kmonth;
$url = get_month_link($kpostyear, $kpostmonth);
$text = sprintf('%s',mysql2date('F Y',$arcresult2-&gt;post_date));
$koutput2 .= get_archives_link($url, $text, '', '
<h2>','</h2>
') . "\n";
if(!$categorized){
if(!$kisinlist) {
$koutput2 .= "
<ul>\n";
$kisinlist=true;					}
}
}if($categorized) {
if($kcurrcat != $arcresult2-&gt;category_id){
$kcurrcat = $arcresult2-&gt;category_id;
if ($kisinlist) {
$koutput2 .= "</ul>
\n";
$kisinlist = false;
}
$koutput2 .= "
<h3>" . $arcresult2-&gt;cat_name . "</h3>
\n
<ul>\n";
$kisinlist = true;
}
}			if ($arcresult2-&gt;post_date != '0000-00-00 00:00:00') {
$url = get_permalink($arcresult2-&gt;ID);
if ('' != $permalink &amp;&amp; 'draft' != $post-&gt;post_status) {
$category = '';
if (strstr($permalink, '%category%')) {
$cats = get_the_category($arcresult2-&gt;ID);
$category = $cats[0]-&gt;category_nicename;
if ($parent=$cats[0]-&gt;category_parent) $category = get_category_parents($parent, FALSE, '/', TRUE) . $category;
}
$unixtime = strtotime($arcresult2-&gt;post_date);
$rewritereplace = array(
date('Y', $unixtime),
date('m', $unixtime),
date('d', $unixtime),
date('H', $unixtime),
date('i', $unixtime),
date('s', $unixtime),
$arcresult2-&gt;post_name,
$arcresult2-&gt;ID,
$category,
$arcresult2-&gt;post_author,
$arcresult2-&gt;post_name
);
$url = apply_filters('post_link', get_settings('home') . str_replace($rewritecode, $rewritereplace, $permalink));
} else {
$url = get_settings('home') . "/?p=" . $arcresult2-&gt;ID;
}
$arc_title = $arcresult2-&gt;post_title;
if ($arc_title) $text = strip_tags($arc_title);} else {
$text = $arcresult2-&gt;ID;
}$koutput2 .= "
	<li>" . mysql2date('d', $arcresult2-&gt;post_date) . ':' . get_archives_link($url, $text, '');
$comments = mysql_query("SELECT * FROM " . $wpdb-&gt;comments . " WHERE comment_approved = '1' AND comment_post_ID=" . $arcresult2-&gt;ID);
$comments_count = mysql_num_rows($comments);
if ($arcresult2-&gt;comment_status == "open" OR $comments_count &gt; 0){
$koutput2 .= ' ('.$comments_count.')';
}
$koutput2 .= "</li>
\n";
}
$koutput2 .= "</ul>
\n
\n";
}
return $koutput2;
}
function kg_archives($type,$initialmonth,$excludecats) {
global $wpdb;
if(! is_page($archive_page_slug)){
return $content;
}
$kselectedmonth = "";
if(strtolower($initialmonth) != "all"){
$kselectedmonth = "";
} else {
$kselectedmonth = $initialmonth;
}
if(isset($_POST['archmonth'])){
$kselectedmonth = $_POST['archmonth'];
}
$kgresults = kgmonthslist();
$koutput1 = "Alle Monate\n";
if($kgresults) {
$kmonthcount = 0;
foreach($kgresults as $kgresult){
$showmonth = mysql2date('F Y',$kgresult-&gt;post_date);
$archmonth = mysql2date('Y-m-',$kgresult-&gt;post_date);
$kselected = "";
if($archmonth == $kselectedmonth){
$kselected = " selected=\"selected\" ";
}
if($kmonthcount++ &lt; 1 &amp;&amp; empty($kselectedmonth)){
$kselected = " selected=\"selected\" ";
$kselectedmonth = $archmonth;
}
$koutput1 .= "".$showmonth."\n";
}
}
$koutput1 = "
<form id="\" action="\" method="\">\n <select name="\" id="\" onchange="\"></select>\n";
$koutput1 .= "
<input id="\" value="\" type="\" />\n </form>\n";
$koutput1 .= fetchArchives($type,$kselectedmonth,$excludecats);
echo $koutput1; // Die Änderung!!!
}
function kg_dropdown($url_to_archives){
global $wpdb;
$kselectedmonth = "";
$initialmonth = "all";
if(strtolower($initialmonth) != "all"){
$kselectedmonth = "";
} else {
$kselectedmonth = $initialmonth;
}
if(isset($_POST['archmonth'])){
$kselectedmonth = $_POST['archmonth'];
}
$kgresults = kgmonthslist();
$koutput1 = "Alle anzeigen\n";
if($kgresults) {
$kmonthcount = 0;
foreach($kgresults as $kgresult){
$showmonth = mysql2date('F Y',$kgresult-&gt;post_date);
$archmonth = mysql2date('Y-m-',$kgresult-&gt;post_date);
$kselected = "";
if($archmonth == $kselectedmonth){
$kselected = " selected=\"selected\" ";
}
if($kmonthcount++ &lt; 1 &amp;&amp; empty($kselectedmonth)){
$kselected = " selected=\"selected\" ";
$kselectedmonth = $archmonth;
}
$koutput1 .= "".$showmonth."\n";
}
}
$koutput1 = "
<form id="\" action="\" method="\">\n <select name="\" id="\" onchange="\"></select>\n";
$koutput1 .= "
<input id="\" value="\" type="\" />\n </form>\n";
print $koutput1;
}
function kgmonthslist($klimit='',$order='DESC') {
global $wpdb;
$kgresults;
if(!isset($kmonthlist)){
$kgresults = $wpdb-&gt;get_results("SELECT DISTINCT post_date, YEAR(post_date) AS year, MONTH(post_date) AS month, count(ID) as posts FROM $wpdb-&gt;posts WHERE post_date &lt; now() AND post_status = 'publish' GROUP BY YEAR(post_date), MONTH(post_date) ORDER BY post_date $order " . $klimit);
$kmonthlist = $kgresults;
}
return $kmonthlist;
}
?&gt;

Ähnliche Beiträge:
WordPress (Up-to-Date)
Neue Domain
Ausfälle der Seite
Umzug
Serverwechsel & Blog-URL

Kommentieren


Ähnliche Beiträge:
WordPress (Up-to-Date)
Neue Domain
Ausfälle der Seite
Umzug
Serverwechsel & Blog-URL

Kommentieren