<?xml version="1.0" encoding="UTF-8"?>
<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/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Texto.de - Mein WordPress Magazin &#187; loop</title>
	<atom:link href="http://www.texto.de/tag/loop/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.texto.de</link>
	<description>Tutorials zu  WordPress als Blog, WordPress als CMS, WP SEO tauglich machen - einfach ein WP Nachschlagewerk</description>
	<lastBuildDate>Tue, 31 Jan 2012 22:41:38 +0000</lastBuildDate>
	<language>de</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Loop &#8211; hör einfach mal wieder auf &#8230;</title>
		<link>http://www.texto.de/loop-hoer-einfach-mal-wieder-auf-1305/</link>
		<comments>http://www.texto.de/loop-hoer-einfach-mal-wieder-auf-1305/#comments</comments>
		<pubDate>Sat, 05 Nov 2011 06:50:32 +0000</pubDate>
		<dc:creator>texto</dc:creator>
				<category><![CDATA[Tipps und Tricks]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[WordPress Quick Tipps]]></category>

		<guid isPermaLink="false">http://www.texto.de/?p=1305</guid>
		<description><![CDATA[Ein Loop holt alle benötigten Daten für einen Artikel oder eine Seiten aus der WordPress Datenbank. Doch wie beendet man diese Schleife so, damit man mehrere Loops verwenden kann. Hier die Lösung.]]></description>
			<content:encoded><![CDATA[<dl class="left" style="width:260px;">
<dt>&nbsp;</dt>
<dd><img  src="http://www.texto.de/wp-images/loop-wordpress-mts.gif" alt="WordPress Loop in Action viele Beispiele" width="250" height="250" /></dd>
</dl>
<p>Du möchtest mehrere Loops in einem Template nutzen. Doch beim Ausprobieren erkanntest Du, dass die sich gegenseitig beeinflussen können.  Dies passiert, wenn man einen Loop nicht befiehlt &#8220;aufzuhören&#8221;. </p>
<p>Dazu bietet WP mehrere Möglichkeiten, wie wann welche gut hilft, erklärt Fantastisch einfach    Jeff Starr. </p>
<p>  <span id="more-1305"></span></p>
<blockquote><p>
wp_reset_postdata() -> am besten nach individuellen oder mehrfachen Loops mit  WP_Query<br />
wp_reset_query() -> am besten nach  query_posts oder nach einem individuellen Loop<br />
rewind_posts() -> am besten, wenn man dasselbe query öfter auf einer Seitenutzen mag<br />
<small>einfache Übersetzung ist von mir .. Original bei:</small><br />
<cite><a href="http://digwp.com/2011/09/3-ways-to-reset-the-wordpress-loop/#article-summary " title="Loops beenden">Jeff Starr</a></cite></p></blockquote>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. Original article:  <a href="http://www.texto.de/loop-hoer-einfach-mal-wieder-auf-1305/" >texto.de</a> (Digital Fingerprint:  textoakamts[texto.de])</small><hr />]]></content:encoded>
			<wfw:commentRss>http://www.texto.de/loop-hoer-einfach-mal-wieder-auf-1305/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Statische Seite X zeigt Beitr&#228;ge von Kategorie Y an.</title>
		<link>http://www.texto.de/statische-seite-x-zeigt-beitraege-von-kategorie-y-an-170/</link>
		<comments>http://www.texto.de/statische-seite-x-zeigt-beitraege-von-kategorie-y-an-170/#comments</comments>
		<pubDate>Thu, 03 Nov 2011 22:37:14 +0000</pubDate>
		<dc:creator>texto</dc:creator>
				<category><![CDATA[Tipps und Tricks]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[wordpress-cms]]></category>

		<guid isPermaLink="false">http://www.texto.de/?p=170</guid>
		<description><![CDATA[Update 2011: Neue Technik. Ich mag Beitr&#228;ge einer bestimmten Kategorie nur anzeigen, wenn man auf einer bestimmten statischen Seite ist. Dies kann man in WordPress leicht lösen.]]></description>
			<content:encoded><![CDATA[<dl class="left" style="width:260px;">
<dt>&nbsp;</dt>
<dd><img  src="http://www.texto.de/wp-images/loop-wordpress-mts.gif" alt="WordPress Loop in Action viele Beispiele" width="250" height="250" /></dd>
</dl>
<p><span class="caplize">A</span>ngefragt wurde ich, wie man es in WordPress schafft, dass man beim Aufrufen der statischen Seite X soundsoviele Beitr&auml;ge aus der Kategorie Y angezeigt bekommt.  </p>
<div class="eyecatch">Diese Anfrage kam im Februar 2006 und daher veröffentlichte ich am 1. März 2006 das erste Mal diesen Artikel. Heute habe ich ihn komplett neu geschrieben und trage damit den veränderten Möglichkeiten in WordPress Rechnung. </div>
<p>Als Vorbereitung für diese Lösung musst Du:</p>
<ol>
<li>Admincenter//Dashboard==>Seiten==>ID der Seite suchen und merken.
</li>
<li>Admincenter//Dashboard==>Artikel==>Kategorien==>ID der Kategorie suchen und merken.
</li>
</ol>
<p>In meinem Beispiel ist die ID der Seite 9.<br />
Die ID der Kategorie ist 3.<br />
Eingetragen habe ich es in meiner sidebar.php.</p>
<h3>ein benutzerdefinierter Loop &#8211; beeinflusst der auch andere </h3>
<p>Diese Lösung funktioniert vor dem normalen Loop und nach dem normalen Loop und wie immer habe ich eine sehr einfache Erklärung mit dabei. <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />   Und ich kanns nicht oft genug erwähnen. Dieser Loop beeinflusst andere Loops nicht! </p>
<p><span id="more-170"></span></p>
<p> Direkt in die page.php kann man dies schreiben.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
 <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'9'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// ID der gewünschten Seite ?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$tmp_post</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'numberposts'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'offset'</span><span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'category'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">6</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$myposts</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$args</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$myposts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> setup_postdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_time<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d.m.:'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; rel=&quot;bookmark&quot; title=&quot;  <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;.
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span>  <span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tmp_post</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> 
&nbsp;
 &lt;/ul&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p><strong>Erkl&auml;rung</strong>:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_page<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'9'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #666666; font-style: italic;">// ID der gewünschten Seite ?&gt;</span></pre></div></div>

<p>Das heißt ausgesprochen:<br />
Wenn es die Seite mit der ID 9 ist, dann&#8230;</p>
<p>Das &lt;ul&gt; öffnet die ungeordnete Liste, in der ich die Beitr&auml;ge anzeigen lassen mag => logisch kannst Du das ändern.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$tmp_post</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$args</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span> <span style="color: #0000ff;">'numberposts'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">6</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'offset'</span><span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'category'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #cc66cc;">6</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$myposts</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span> <span style="color: #000088;">$args</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$myposts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> setup_postdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Meine Erklärungen sind meist sehr bildhaft <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Liebes WordPress, du glaubst zwar jetzt gehts um eine Seite, doch ich gebe dir nun den Befehl zeige Artikel an,<br />
und zwar 6 (numberposts), aber nicht die ersten 3 (offset) und zwar nur aus der Kategorie mit der ID 6.</p>
<p>Und hole alles was zu einem Artikel dazugehört aus der Datenbank raus (setup_postdata). </p>
<p class="eingerueckt">===>  Du könntest also auch Autoren, benutzerdefinierte Felder etc anzeigen lassen. </p>
<p>Jetzt wird angegeben wie die Beitr&auml;ge aussehen sollen:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
&lt;li&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_time<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'d.m.:'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; rel=&quot;bookmark&quot; title=&quot; <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;.&lt;/li&gt;</pre></div></div>

<p>Hier hast Du freie Wahl. Ich lasse zuerst das Datum anzeigen, dann nur den Link zum Beitrag.<br />
Packe dann alles zwischen die &lt;li&gt; und &lt;/li&gt;, damit die Liste richtig wird.   </p>
<h3> alles bis zum &#8220;more-tag&#8221;&#8230;. </h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$more</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$more</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
the_content<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Weiterlesen'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>den Loop   beenden &#8211; so damit er andere Loops nicht stört</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span>  <span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tmp_post</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Dies ist wichtig, damit WordPress wei&#223;, es muss nicht mehr weiterarbeiten. (endforeach) und dies beendet den Loop komplett, sodass weitere Loops nicht von diesem beeinflusst werden  ( $ post = $ tmp_post )</p>
<p>Abfrage, ob man auf der richtigen Seite ist mag auch beendet werden&#8230;.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Schlie&#223;t den ganzen Komplex, der mit if&#8230;. anfing.</p>
<p><strong>Artikelhistorie:</strong></p>
<p>Erstveröffentlichung: 01. März 2006 19:59<br />
Update: 3.11.2011</p>
<p>Viel Spa&#223; beim Ausprobieren. </p>
<div class="sign"> bei Fragen einfach fragen..</div>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. Original article:  <a href="http://www.texto.de/statische-seite-x-zeigt-beitraege-von-kategorie-y-an-170/" >texto.de</a> (Digital Fingerprint:  textoakamts[texto.de])</small><hr />]]></content:encoded>
			<wfw:commentRss>http://www.texto.de/statische-seite-x-zeigt-beitraege-von-kategorie-y-an-170/feed/</wfw:commentRss>
		<slash:comments>31</slash:comments>
		</item>
		<item>
		<title>Templates machen das Leben einfacher &#8211;  vergiss query_posts</title>
		<link>http://www.texto.de/templates-machen-das-leben-einfacher-vergiss-query_posts-1302/</link>
		<comments>http://www.texto.de/templates-machen-das-leben-einfacher-vergiss-query_posts-1302/#comments</comments>
		<pubDate>Thu, 06 Oct 2011 20:21:41 +0000</pubDate>
		<dc:creator>texto</dc:creator>
				<category><![CDATA[Tipps und Tricks]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://www.texto.de/?p=1302</guid>
		<description><![CDATA[query_posts verändert die Ausgabe des Standard Loops. Individuelle Templates können sehr oft query_posts ersetzen. Hier einige Tipps dazu. ]]></description>
			<content:encoded><![CDATA[<dl class="left" style="width:260px;">
<dt>&nbsp;</dt>
<dd><img  src="http://www.texto.de/wp-images/loop-wordpress-mts.gif" alt="WordPress Loop in Action viele Beispiele" width="250" height="250" /></dd>
</dl>
<p><span class="caplize">H</span>ierarchie all überall auch in der WordPress Welt <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .<br />
Für den Redakteur soll die Profilseite schon anders aussehen, als für den Autor. query_posts author=6</p>
<p>Und meine Portfolio Kategorie hat sich ein ganz eigenes Aussehen einfach verdient! query_posts cat=345</p>
<p>In all meiner Auflistung der Musiker (mittels custom taxonomien) ist mir Britney einfach was schöneres wert&#8230;. usw.   query_posts   array    &#8216;musiker&#8217; => &#8216;britney&#8217; </p>
<p>Immer wenn es darum geht eine bestimmte Ausnahme in der Darstellung zu machen sehe ich dann Konstrukte mit Loops. <strong>query_posts</strong> ist da allgemein sehr beliebt.</p>
<p>Man sucht sich in den diversen loop.php Dateien kreuz und quer, sucht verzweifelt nach if-Schleifen, die aber doch if-Abfragen sind und kennt sich schlussendlich selbst nicht mehr aus. Haare werden Grau, Falten beginnen die Nasenwurzel zu zieren&#8230;</p>
<p>Und das alles nur wegen <b>query_posts</b>. Ich bin ja strikt dafür dies aus dem Codex zu entfernen. Ratzefatz weg damit, denn was macht dieser so offensichtlich einfache Loop.  </p>
<p><span id="more-1302"></span></p>
<h3>Was macht  query_posts</h3>
<p>zb</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">query_posts<span style="color: #009900;">&#40;</span> author<span style="color: #339933;">=</span><span style="color: #cc66cc;">5</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
get_header<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span> have_posts<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span>
get_footer<span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<blockquote><p>
query_posts ist die einfachste Art die Standard Ausgabe der Artikel pro URL zu ändern.<br />
zb Archiv, Kategorie, Tagseite, Startseite, Einzelansicht eines Artikels.</p>
<p><cite>Codex zu <a href="http://codex.wordpress.org/Function_Reference/query_posts" title="Codex">query_posts</a></cite></p></blockquote>
<p>Ja, es ist die einfachste Art, doch es zerstört nachhaltigst die natürliche   Ordnung in WordPress. </p>
<p class="eingerueckt">Nutzt Du <strong>query_posts</strong> veränderst Du die gesamte Standardausgabe der Artikel: Angefangen von den template tags bishin zu den globalen Variablen. </p>
<p>=> die meisten verzweifeln , weil dann die Pagination /Weiterblätterei nicht mehr funktioniert.<br />
=> die wenigsten erkennen, dass query_posts immer 2 queries macht. Stichwort: Performance Deines Blogs.</p>
<p><b>Tipp </b>==> Nutze <strong>query_posts</strong> nur, wenn   Dir wirklich absolut und überhaupt keine Alternative mehr einfällt.  Und das ist so selten der Fall.<br />
Und wenn Du es schon nutzt, dann setz den Loop wieder zurück mit wp_reset_query( ) . </p>
<h3>Wie kannst Du query_posts umgehen.</h3>
<p><span class="firstletter">1.</span><br />
Für die Redakteuren eine wunderbare Profilseite: <strong>author-{nickname}.php</strong> oder <strong>author-id.php</strong>.</p>
<p class="eingerueckt">Keiner hat 100derte von Redakteure in seiner WP Installation, diese paar Templates sind schneller erstellt, als stundenlanges suchen nach query_posts Lösungen. </p>
<p><span class="firstletter">2.</span><br />
Für die Portfolio Kategorie ein eigenes Aussehen: <strong>category-slugname.php</strong> oder <strong>category-id.php</strong>. </p>
<p><span class="firstletter">2a.</span><br />
Ist Dein Portfolio ein <strong>custom post type</strong>, dann  <strong>archive-{post_type}.php</strong>  =><strong> archive-portfolio.php</strong> und für die Einzelansichten <strong>single-{post_type}.php</strong> =><strong> single-portfolio.php</strong>.</p>
<p><span class="firstletter">3.</span><br />
Für Deine Britney aus der custom Taxonomie:<strong> taxonomy-{taxonomy}-{term}.php</strong></p>
<p>Ist die Taxonomie Musiker und der Slug der Taxonomie ist britney, dann findet WP auch <strong>taxonomy-musiker-britney.php</strong></p>
<p><b>Fazit:</b> Bevor Du krampfhaft versuchst alles in einem template unterzubringen nutze die <a href="http://www.texto.de/update-cheat-cheet-wp-template-hierarchie-909/" title="Template Hierarchy">Template Hierarchie</a> von WordPress voll aus und Du hast</p>
<p>1. mehr Überblick in deinem ThemeOrdner und<br />
2. weniger Chance je query_posts nutzen zu wollen. <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
<div class="sign"> ich hab es lieber einfacher, denn dreimal ums Eck gedacht..  <img src="http://www.texto.de/wp-images/smilies/icon_confused.gif" alt="Kaffeetrinkender Smilie" width="27" height="21" /></div>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. Original article:  <a href="http://www.texto.de/templates-machen-das-leben-einfacher-vergiss-query_posts-1302/" >texto.de</a> (Digital Fingerprint:  textoakamts[texto.de])</small><hr />]]></content:encoded>
			<wfw:commentRss>http://www.texto.de/templates-machen-das-leben-einfacher-vergiss-query_posts-1302/feed/</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>WP Loop: Teaserartikel-andere Artikel ohne Teaser aber Weiterblättern</title>
		<link>http://www.texto.de/wp-loop-teaserartikel-andere-artikel-ohne-teaser-aber-weiterblaettern-1247/</link>
		<comments>http://www.texto.de/wp-loop-teaserartikel-andere-artikel-ohne-teaser-aber-weiterblaettern-1247/#comments</comments>
		<pubDate>Thu, 15 Sep 2011 17:49:15 +0000</pubDate>
		<dc:creator>texto</dc:creator>
				<category><![CDATA[WP-CMS]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[wordpress-cms]]></category>

		<guid isPermaLink="false">http://www.texto.de/?p=1247</guid>
		<description><![CDATA[Loop in Aktion: Teaserartikel in WordPress erstellen, die folgenden Artikeln ohne Teaserartikel, aber Pagination also Weiterblättern soll weiterhin möglich sein. ]]></description>
			<content:encoded><![CDATA[<dl class="left" style="width:260px;">
<dt>WP Loop</dt>
<dd><img  src="http://www.texto.de/wp-images/loop-wordpress-mts.gif" alt="WordPress Loop in Action viele Beispiele" width="250" height="250" /></dd>
</dl>
<p>Michael von  <a href="http://www.simtimes.de/" title="Simtimes">SimTimes</a> fragte mich via Email: &#8220;Ich möchte den ersten Artikel meines Loops als Teaser-Artikel ausgeben. Aber das Weiterblättern funktioniert dann nicht mehr &#8211; hast Du eine Lösung?&#8221;.</p>
<p>Es gibt dafür jede Menge an Lösungen, ich zeige hier eine, wer weitere Lösungen weiß bitte in die Kommentare schreiben <img src='http://www.texto.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p>Auf Nachfrage erklärte mir Michael, dass sein Teaser Artikel einfach der zuletzt geschriebene Artikel ist. Gesucht hat er hier auf der Texto nach &#8220;first post&#8221;. <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p><span id="more-1247"></span></p>
<p>Ich bringe hier nur die Angaben für die Queries, aber nicht die Darstellung der Artikel. Da steht dann einfach im Code<br />
&lt;!-  -your stuff-  -&gt; Dies ist all das   was normalerweise nach &#8220;while have post the post&#8221; und vor &#8220;endwhile&#8221; steht.</p>
<h3>Loop für den Teaser Artikel</h3>
<p>Alles was jetzt kommt ersetzt  &#8220;if have post while have post the post&#8221;  => und das nachfolgende &#8220;endwhile else endif&#8221; =><br />
also es wird ein komplett neues Template erstellt (! ).</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>    
<span style="color: #000088;">$temp</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wp_query</span><span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wp_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'showposts=1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$do_not_duplicate</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;h1&gt;Deine Überschrift oder Du läßt dies hier einfach weg&lt;/h1&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;!--your stuff--&gt; 
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>showposts=1 => selbsterklärend, zeige 1 Artikel, magst Du mehrere, die Ziffer ändern.<br />
do not duplicate =>sagt WP, pass auf merk Dir diese ID, die darfst Du nämlich später nicht mehr zeigen <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>Loop für die nachfolgenden Artikel ohne den 1. und mit Pagination</h3>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>    
<span style="color: #000088;">$temp</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wp_query</span><span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wp_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'showposts=10&amp;paged='</span><span style="color: #339933;">.</span><span style="color: #000088;">$paged</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;h1&gt;Deine Überschrift oder Du läßt dies hier einfach weg&lt;/h1&gt;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #339933;">==</span> <span style="color: #000088;">$do_not_duplicate</span> <span style="color: #009900;">&#41;</span> <span style="color: #b1b100;">continue</span><span style="color: #339933;">;</span> update_post_caches<span style="color: #009900;">&#40;</span><span style="color: #000088;">$posts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;!--your stuff--&gt; 
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&lt;!--code für das Weiterblättern next page previous page oder ein Plugincode--&gt;
&nbsp;
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #000088;">$wp_query</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #000088;">$wp_query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$temp</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_sidebar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   get_footer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p> paged =paged=> jetzt wirds dann zum Weiterblättern<br />
if &#8230;.do not duplicate  continue update post cache=> wenn es diese ID von oben ist, dann geh einfach weiter, erneuere aber Deinen post cache WP und ab die Post <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<div class="sign"> Ich habe diese beiden Loops nochmals getestet. Sie funktionieren einwandfrei. Wenns geholfen hat freu ich mich übers Weitersagen, ein +1 <img src="http://www.texto.de/wp-images/smilies/icon_confused.gif" alt="Kaffeetrinkender Smilie" width="27" height="21" /></div>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. Original article:  <a href="http://www.texto.de/wp-loop-teaserartikel-andere-artikel-ohne-teaser-aber-weiterblaettern-1247/" >texto.de</a> (Digital Fingerprint:  textoakamts[texto.de])</small><hr />]]></content:encoded>
			<wfw:commentRss>http://www.texto.de/wp-loop-teaserartikel-andere-artikel-ohne-teaser-aber-weiterblaettern-1247/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Quick Tipp: Ähnliche Artikel anhand des 1.Tags anzeigen</title>
		<link>http://www.texto.de/quick-tipp-aehnliche-artikel-anhand-des-1tags-anzeigen-834/</link>
		<comments>http://www.texto.de/quick-tipp-aehnliche-artikel-anhand-des-1tags-anzeigen-834/#comments</comments>
		<pubDate>Sat, 02 May 2009 11:51:26 +0000</pubDate>
		<dc:creator>texto</dc:creator>
				<category><![CDATA[WP-CMS]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[template]]></category>
		<category><![CDATA[WordPress Quick Tipps]]></category>

		<guid isPermaLink="false">http://www.texto.de/?p=834</guid>
		<description><![CDATA[5 Artikel anzeigen, die zum 1.Tag  des Artikels passen. Du magst zusätzliche Artikel unterhalb eines Artikels anzeigen und die sollen sich an dem 1.verwendeten Tag /Schlüsselwort des Artikels orientieren.Hier ein spezieller WordPress Loop als  Lösung vom anderen Ende der Welt ...]]></description>
			<content:encoded><![CDATA[<dl id="attachment_835" class="wp-caption alignleft" style="width: 288px"><dt><img src="http://www.texto.de/wp-images/2009/05/aehnliche-artikel-tag.gif" alt="Ähnliche Artikel zum 1. Tag" title="aehnliche-artikel-tag" width="278" height="144" class="size-full wp-image-835" /></dt><dd class="wp-caption-text">Ähnliche Artikel zum 1. Tag</dd></dl>
<p><span class="caplize">D</span>u nutzt viele Tags und möchtest unterhalb eines Artikels <strong>ähnliche Artikel </strong>anzeigen lassen. Klar kann dies ein Tag Plugin, aber es geht auch ohne und kann so öfter hilfreich sein.  Beim Durchstöbern wer so aller  die Texto besucht fand ich eine WP Seite aus Taiwan und gleich auf der 1. Seite sprang mir eben die Idee zu dieser <strong>ähnlichen Artikel Anzeige</strong> ins Auge und somit präsentiere ich sie hier auf Deutsch <span id="more-834"></span>mit anschließendem Formatierungsvorschlag. </p>
<h3>5 ähnliche Artikel anzeigen anhand des 1.verwendeten Tags eines Artikels</h3>
<p>Dies muss vor dem</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>des Loops geschrieben werden.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//for use in the loop, list 5 post titles related to first tag on current post</span>
<span style="color: #000088;">$tags</span> <span style="color: #339933;">=</span> wp_get_post_tags<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'Related Posts'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$first_tag</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tags</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">term_id</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$args</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'tag__in'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$first_tag</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'post__not_in'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'showposts'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'caller_get_posts'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">1</span>
   <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$my_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
      &lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; rel=&quot;bookmark&quot; title=&quot;Permanent Link to <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title_attribute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;
&nbsp;
      <span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
wp_reset_query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Thanks a lot for sharing your knowledge <img src='http://www.texto.de/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' />  <a href="http://www.wordpress.com.tw/?p=341" title="WordPress.com.tw Max">Max von wordpress.com.tw.</a>.</p>
<p>Nun dies liefert eine unformatierte Ausgabe der Artikel, magst Du diese in eine Liste packen, dann sieht dies so aus:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #666666; font-style: italic;">//for use in the loop, list 5 post titles related to first tag on current post ul list</span>
<span style="color: #000088;">$tags</span> <span style="color: #339933;">=</span> wp_get_post_tags<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$tags</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
<span style="color: #b1b100;">echo</span><span style="color: #0000ff;">'&lt;ul&gt;&lt;li&gt;&lt;b&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&amp;Auml;hnliche Artikel&lt;/b&gt;&lt;/li&gt;'</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$first_tag</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$tags</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">term_id</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$args</span><span style="color: #339933;">=</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span>
    <span style="color: #0000ff;">'tag__in'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$first_tag</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'post__not_in'</span> <span style="color: #339933;">=&gt;</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'showposts'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">5</span><span style="color: #339933;">,</span>
    <span style="color: #0000ff;">'caller_get_posts'</span><span style="color: #339933;">=&gt;</span><span style="color: #cc66cc;">1</span>
   <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #000088;">$my_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #000088;">$args</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
      &lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; rel=&quot;bookmark&quot; title=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title_attribute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/li&gt;
&nbsp;
      <span style="color: #000000; font-weight: bold;">&lt;?php</span>
    <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">echo</span><span style="color: #0000ff;">'&lt;/ul&gt;'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span>
wp_reset_query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<div class="sign">Viel Freud damit und nochmals Danke an Max aus Taiwan.  </div>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. Original article:  <a href="http://www.texto.de/quick-tipp-aehnliche-artikel-anhand-des-1tags-anzeigen-834/" >texto.de</a> (Digital Fingerprint:  textoakamts[texto.de])</small><hr />]]></content:encoded>
			<wfw:commentRss>http://www.texto.de/quick-tipp-aehnliche-artikel-anhand-des-1tags-anzeigen-834/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Hauptkategorie zeigt alle Unterkategorien mit Artikel an</title>
		<link>http://www.texto.de/hauptkategorie-zeigt-alle-unterkategorien-mit-artikel-an-722/</link>
		<comments>http://www.texto.de/hauptkategorie-zeigt-alle-unterkategorien-mit-artikel-an-722/#comments</comments>
		<pubDate>Thu, 05 Mar 2009 17:04:45 +0000</pubDate>
		<dc:creator>texto</dc:creator>
				<category><![CDATA[Tipps und Tricks]]></category>
		<category><![CDATA[loop]]></category>

		<guid isPermaLink="false">http://www.texto.de/?p=722</guid>
		<description><![CDATA[Die Hauptkategorie soll alle Unterkategorien mit einigen Artikeln anzeigen. Childcategories on a parent category page. Hier eine Lösung.]]></description>
			<content:encoded><![CDATA[<dl class="left" style="width:410px;">
<dt> &nbsp;</dt>
<dd><img src="http://www.texto.de/wp-images/0309/childcategories-on-parentcategory.gif" alt=" Childcategories on parentcategory" width="400" height="304" /></dd>
<dd>childcategories on parentcategory</dd>
</dl>
<p><span class="caplize">D</span>u möchtest, dass man beim Klick auf die Hauptkategorie die Unterkategorien sieht mit einigen ihrer Artikel und einen *weiterlesen* Link, der zur jeweiligen Unterkategorie führt.</p>
<h3>Hauptkategorie keinen Artikel</h3>
<p>Dies ist nur sinnvoll, wenn man  in der Hauptkategorie keinen Artikel hat. Aber mancher mag dies so, weil er so  wichtige Worte in der URL unterbringt und   seinen Besuchern genug Überblick durch die Aufteilung bieten kann. </p>
<h3>Umblättern &#8211; Pagination</h3>
<p>Ich habe diese Auflistung der Unterkategorien mit Artikeln absichtlich nicht <span id="more-722"></span>zum *Umblättern* hergerichtet, weil dies ja wiederum den Überblick schmälert und 2. programmiertechnisch ein wenig mehr Aufwand wäre, der wegen des fehlenden Überblicks für die Besucher wiederum umsonst wäre. <img src='http://www.texto.de/wp-includes/images/smilies/zwinker.gif' alt=':zwinker:' class='wp-smiley' /> </p>
<h3>Category.php html und Sprache anpassen</h3>
<p>Die erstellte <strong>category.php</strong> stell ich als <a href="http://www.texto.de/count/downloadcounter.php?stwc_cz=1&amp;stwc_id=16" title="Download category.php"><strong>.zip Datei </strong></a>zur Verfügung. Ich ersuche das <abbr title="Hyper Text Markup Language"><span class="abbr" title="Hyper Text Markup Language">HTML</span></abbr> anzupassen und außerdem ist das Template für Übersetzungen vorbereitet, da muss man dann sicher den &#8220;Projektnamen&#8221; ändern. </p>
<p>Diese category.php bietet sowohl Unterkategorien auf der Hauptkategorieseite wie eine ganz normale Kategorienansicht, die den *weiterlesen Link* zeigt. </p>
<p>Dies hat den Vorteil, dass man völlig frei Kategorien ohne Unterkategorien haben kann, aber auch Hauptkategorien mit Unterseiten, die man dann eben in der Hauptkategorie herzeigt. </p>
<h3>unterschiedliche templates für unterschiedliche Kategorien</h3>
<p>Die Mischung:1x Unterkategorien auf der Haupt-Kategorie anzeigen und 1x nicht ist höchst verwirrend für den Besucher, daher rate ich davon ab. Außerdem kann man dies nicht automatisieren, weil WP einfach nicht weiß, was Du Dir als Admin denkst . <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>Wer mag kann sich den Code hier ansehen. </h3>
<p>Es ist viel, ich warne <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </p>
<div class="eyecatch">
<p>Download der Hauptkategorie zeigt Unterkategorien <a href="http://www.texto.de/count/downloadcounter.php?stwc_cz=1&amp;stwc_id=16" title="Download category.php">category.php als .zip Datei</a>. </p>
</div>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>		
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$numposts</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">3</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// # posts to display; -1 for all</span>
<span style="color: #000088;">$cat_obj</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_queried_object</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$cat_obj</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">parent</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
	<span style="color: #000088;">$child_posts</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$cat_obj</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">term_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;numberposts='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$numposts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$child_posts</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;h3 class=&quot;archive&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Archive for'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mtsdreaming'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$cat_obj</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h3&gt;		
&lt;ul&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$child_posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>		
  &lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; title=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title_attribute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/li&gt;
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>		
&lt;/ul&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">else</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;h3 class=&quot;archive&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Archive for'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mtsdreaming'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$cat_obj</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h3&gt;
&lt;div <span style="color: #000000; font-weight: bold;">&lt;?php</span> post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt; 
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
 	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
 	<span style="color: #000088;">$categories</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">get_results</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SELECT <span style="color: #006699; font-weight: bold;">$wpdb-&gt;terms</span>.term_id, <span style="color: #006699; font-weight: bold;">$wpdb-&gt;terms</span>.name from <span style="color: #006699; font-weight: bold;">$wpdb-&gt;terms</span> INNER JOIN <span style="color: #006699; font-weight: bold;">$wpdb-&gt;term_taxonomy</span> ON <span style="color: #006699; font-weight: bold;">$wpdb-&gt;terms</span>.term_id = <span style="color: #006699; font-weight: bold;">$wpdb-&gt;term_taxonomy</span>.term_id WHERE taxonomy = 'category' AND parent = '<span style="color: #006699; font-weight: bold;">{$cat_obj-&gt;term_id}</span>' ORDER BY name ASC&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 	<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$categories</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$category</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>
 		<span style="color: #000088;">$child_posts</span> <span style="color: #339933;">=</span> get_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'category='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">term_id</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">'&amp;numberposts='</span> <span style="color: #339933;">.</span> <span style="color: #000088;">$numposts</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
 		<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$child_posts</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
  &lt;h3 class=&quot;archive&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$category</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">name</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h3&gt; 		
  &lt;ul class=&quot;clearfix&quot;&gt;   
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span> <span style="color: #000088;">$child_posts</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$post</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> 		setup_postdata<span style="color: #009900;">&#40;</span><span style="color: #000088;">$post</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span> 		
    &lt;li&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; title=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title_attribute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;  
    &lt;br /&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span>get_the_excerpt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/li&gt;   
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
    &lt;li class=&quot;readmore&quot;&gt;
      <span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">' &amp;raquo; &amp;raquo; more Articles:'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mtsdreaming'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
      <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_category<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/li&gt;     
  &lt;/ul&gt; 
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endforeach</span><span style="color: #339933;">;</span> <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;&lt;!--end of childcategories on parentcategory--&gt;    
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span> <span style="color: #339933;">!</span><span style="color: #000088;">$child_posts</span> <span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span>  <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>		 
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$post</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$posts</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// Hack. Set $post so that the_date() works. ?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>is_category<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>				 		
&lt;p class=&quot;archive&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">echo</span> <span style="color: #990000;">strip_tags</span><span style="color: #009900;">&#40;</span>category_description<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/p&gt;	
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>	
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>have_posts<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> the_post<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;div <span style="color: #000000; font-weight: bold;">&lt;?php</span> post_class<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&gt; 
&lt;h2&gt;&lt;a href=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_permalink<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot; rel=&quot;bookmark&quot; title=&quot;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title_attribute<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/a&gt;&lt;/h2&gt;  		   
  <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_content<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;raquo;&amp;raquo;  &quot;</span> <span style="color: #339933;">.</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> <span style="color: #009900; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> 		   
  &lt;p class=&quot;metadata&quot;&gt;				     
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> _e<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Filed under:'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mtsdreaming'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>      
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> the_category<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">','</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span> |      
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>get_the_tags<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> the_tags<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">''</span><span style="color: #339933;">,</span><span style="color: #0000ff;">','</span><span style="color: #339933;">,</span><span style="color: #0000ff;">' |'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>     
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> comments_popup_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'No Comments'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mtsdreaming'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'1 Comment'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mtsdreaming'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'% Comments'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mtsdreaming'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">,</span> __<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'Comments off'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mtsdreaming'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>     
    <span style="color: #000000; font-weight: bold;">&lt;?php</span> edit_post_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'edit'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mtsdreaming'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span><span style="color: #0000ff;">' | '</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>   
  &lt;/p&gt;    
&lt;/div&gt;&lt;!--end of post--&gt;		
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span>endif<span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_page_numbers'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  wp_page_numbers<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">echo</span> <span style="color: #0000ff;">'&lt;br class=&quot;clear&quot;/&gt;'</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>  <span style="color: #b1b100;">elseif</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #990000;">function_exists</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'wp_page_numbers'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
<span style="color: #b1b100;">echo</span><span style="color: #0000ff;">'&lt;p class=&quot;navigate&quot;&gt;'</span><span style="color: #339933;">;</span>
 next_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;laquo; Previous Entries |'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mtsdreaming'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span> 
   previous_posts_link<span style="color: #009900;">&#40;</span>__<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'| Next Entries &amp;raquo;'</span><span style="color: #339933;">,</span><span style="color: #0000ff;">'mtsdreaming'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">;</span> 
 <span style="color: #b1b100;">echo</span><span style="color: #0000ff;">'&lt;/p&gt;'</span><span style="color: #339933;">;</span><span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">?&gt;</span> 	
<span style="color: #000000; font-weight: bold;">&lt;?php</span>  <span style="color: #b1b100;">endif</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_sidebar<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> get_footer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Bei Fragen einfach fragen. </p>
<div class="sign">Über einen Bookmark oder einen Link freu ich mich,wenn es hiflreich war.  Viel Spaß! </div>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. Original article:  <a href="http://www.texto.de/hauptkategorie-zeigt-alle-unterkategorien-mit-artikel-an-722/" >texto.de</a> (Digital Fingerprint:  textoakamts[texto.de])</small><hr />]]></content:encoded>
			<wfw:commentRss>http://www.texto.de/hauptkategorie-zeigt-alle-unterkategorien-mit-artikel-an-722/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Artikel alphabetisch sortieren &#8211; nach Titel &#8211; nach benutzerdefinierten Feldern</title>
		<link>http://www.texto.de/artikel-alphabetisch-sortieren-titel-benutzerdefinierten-feldern-765/</link>
		<comments>http://www.texto.de/artikel-alphabetisch-sortieren-titel-benutzerdefinierten-feldern-765/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 08:30:36 +0000</pubDate>
		<dc:creator>texto</dc:creator>
				<category><![CDATA[Tipps und Tricks]]></category>
		<category><![CDATA[custom-fields]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[template]]></category>

		<guid isPermaLink="false">http://www.texto.de/?p=765</guid>
		<description><![CDATA[Artikel in Wordpress  alphabetisch sortieren. Mit Überschrift oder ohne. Artikel nach benutzerdefinierten Feldern -custom-fields  sortieren. Die Anzeige auf einer statischen Seite - und dies alles mit ganz wenigen Klicks.]]></description>
			<content:encoded><![CDATA[<dl class="left" style="width:360px;">
<dt> Artikel A-Z&nbsp;</dt>
<dd><img src="http://www.texto.de/wp-images/0109/artikel-a-z.gif" alt=" Artikeln A-Z geordnet" width="352" height="356" /></dd>
</dl>
<p><span class="caplize">A</span>rtikel alphabetisch sortieren. Mit Überschrift oder ohne. Artikel nach benutzerdefinierten Feldern sortieren. Die Anzeige auf einer statischen Seite &#8211; und dies alles mit ganz wenigen Klicks.  Wunderbar ist das. Das WordPress Plugin A-Z Index  kann dies &#8211; und vielleicht noch mehr. </p>
<h3>Wofür ist so eine Sortierung brauchbar</h3>
<ol>
<li>Buchbesprechungen</li>
<li>Hitlisten</li>
<li>CD Sammlungen</li>
<li>Torjäger</li>
<li>Spielerlisten</li>
<li>Glossar</li>
<li>u.v.m</li>
</ol>
<p><br  class="clear" /></p>
<p><span id="more-765"></span></p>
<h3>A-Z Index WordPress Plugin installieren</h3>
<ul>
<li>Herunterladen.</li>
<li>Entpacken.</li>
<li>Admincenter==>Plugins==>Aktivieren</li>
<li>Admincenter==>Werkzeuge==>AZ Index anklicken.</li>
<li>Ausprobieren <img src='http://www.texto.de/wp-includes/images/smilies/zwinker.gif' alt=':zwinker:' class='wp-smiley' /> </li>
<li>Die statischen Seiten werden vom Plugin erstellt.</li>
</ul>
<h3>Benutzerdefinierte Felder </h3>
<p>Die sollten vorher erstellt und benutzt worden sein, sonst hat das Plugin nichts zu sortieren, außer man mag nach Titeln sortieren.</p>
<h3>Englishe Beschreibungen der Sortiermöglichkeiten </h3>
<p>Ich empfehle dict.leo.org, wenn wer irgend ein Vokabel nicht versteht. Unabhängig davon, einfach mal anhaken und sehen was passiert &#8211; erkennen &#8211; <span lang="en"  xml:lang="en">learning by trial &#038; error &#8211; this are the best taskmaster </span> <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>Hier ist ein großer Screenshot der Einstellungsmöglichkeiten: <a href="http://www.texto.de/wp-images/0109/add-index-einstellungen.gif" title="Screenshot der A-Z Index Options Page"><strong>Screenshot der Options Page von AZ Index</strong></a>.</p>
<h3>Umlaute</h3>
<p>Alle Artikel, deren Titel mit einem Umlaut beginnen finden sich am Ende der Liste. z B.: Ö steht am Ende als O. Dies hängt vion der Datenbank ab wurde mir gesagt, aber der Autor &#8220;English Mike&#8221; sucht eine Lösung. </p>
<div class="sign"> Danke für dieses einfach zu nutzende Plugin sag ich dem Autor und uns allen viel Freud damit </div>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. Original article:  <a href="http://www.texto.de/artikel-alphabetisch-sortieren-titel-benutzerdefinierten-feldern-765/" >texto.de</a> (Digital Fingerprint:  textoakamts[texto.de])</small><hr />]]></content:encoded>
			<wfw:commentRss>http://www.texto.de/artikel-alphabetisch-sortieren-titel-benutzerdefinierten-feldern-765/feed/</wfw:commentRss>
		<slash:comments>11</slash:comments>
		</item>
		<item>
		<title>WP 2.7 Spielereien mit sticky Artikel-Artikel oben festpinnen</title>
		<link>http://www.texto.de/wp-27-sticky-artikel-678/</link>
		<comments>http://www.texto.de/wp-27-sticky-artikel-678/#comments</comments>
		<pubDate>Sat, 29 Nov 2008 07:50:59 +0000</pubDate>
		<dc:creator>texto</dc:creator>
				<category><![CDATA[WP-CMS]]></category>
		<category><![CDATA[loop]]></category>

		<guid isPermaLink="false">http://www.texto.de/?p=678</guid>
		<description><![CDATA[WordPress 2.7 ermöglicht ganz einfach einen Artikel auf der Startseite festzupinnen. Featured Articles wird dies auch oft genannt. WP 2.7 nennt dies sticky posts. Wie kann man sie designen. Worauf muss man bei speziellen Loops achten. Wie kann man sie verhindern. Hier die Lösungen dazu.]]></description>
			<content:encoded><![CDATA[<dl class="left" style="width:310px;">
<dt> Sticky Artikel</dt>
<dd><img src="http://www.texto.de/wp-images/1108/sticky-post.gif" alt=" WP 2.7 Sticky Artikel" width="302" height="228" /></dd>
</dl>
<p> <span class="caplize">A</span>rtikel besonders hervorheben ist eine beliebte Gestaltungsmöglichkeit geworden. Magman einen Artikel außer der zeitlichen Reihenfolge oben festpinnen, festnageln braucht man ab WP 2.7 kein Plugin mehr dafür. Sticky Posts kann man dann einfach beim Schreiben erstellen.<br class="clear" /></p>
<p>In dem *Veröffentlichungskästchen* muss man nur ein Häkchen setzen. Dies ist der ganz einfache Teil, doch wie kann man jetzt diese sticky Artikel gestalten? Worauf muss man achten, wenn man individuelle Loops auf der Startseite nutzt? Wie geht das, dass der sticky Artikel unterhalb nicht wieder auftaucht? </p>
<p>Auf all diese Fragen und mehr gehe ich in diesem Artikel <span id="more-678"></span>hier ein. Und wie immer, bei Fragen einfach Fragen. <img src='http://www.texto.de/wp-includes/images/smilies/zwinker.gif' alt=':zwinker:' class='wp-smiley' /> </p>
<h3>Artikel ist bereits veröffentlicht-kann er dennoch zum sticky Artikel werden?</h3>
<dl class="left" style="width:310px;">
<dt>Quick Edit</dt>
<dd><a href="http://www.texto.de/wp-images/1108/quick-edit.gif" title="Große Vorschau der Quick Edit Funktion"><img src="http://www.texto.de/wp-images/1108/quick-edit-kl.gif" alt=" das schnelle Editieren in WP 2.7" width="302" height="228" /></a></dd>
<dd>Quick Edit ganz groß</dd>
</dl>
<p>Ja. Öffnet man den Menüpunkt &#8220;Artikel==>Bearbeiten&#8221; in WP 2.7 kann man mit Klick auf &#8220;Quick Edit&#8221; ganz rasch einen Artikel als &#8220;sticky&#8221; hervorheben. Und noch mehr, doch dies ein ander Mal.;)<br class="clear"/></p>
<h3>sticky Artikel gestalten</h3>
<p>Um einen sticky Artikel einfach gestalten zu können, ist es nötig den neuen WP Template tag post_class zu verwenden, den ich in bereits vorgestellt habe: <a href="http://www.texto.de/texto/wp-27-neuer-template-tag-post-class/" title="Template Tag post_class">WP 2.7. neuer Template Tag post_class</a>.</p>
<p>Jetzt bietet aber post_class viele CSS classes an. Mag man verhindern, dass die sticky Artikel auch in der Kategorieübersicht oder anderen Archiven speziell gestaltet sind, muss man dort entweder ein eigenes div class archiv nutzen, um dies zu verhindern. Da dies oft sehr speziell ist, gebe ich gern Direkthilfe in den Kommentaren, weil es fast unmöglich ist generell hier Auskunft zu geben. </p>
<p>Dies ist eben einer der Nachteile, wenn ein Template Tag viele CSS classes anbietet. </p>
<h3>Kann ich abfragen, ob ein Artikel sticky ist?</h3>
<p>Ja. WP 2.7 bietet den neuen Conditional Tag:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
is_sticky<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span></pre></div></div>

<p>dafür an. Andere Conditional Tags findest Du hier in dem Artikel über die <a href="http://www.texto.de/update-cheat-cheet-wp-template-hierarchie-909/" title="Template Hierarchy und Conditional Tags">Template Hierarchie in WP</a>.</p>
<h3>Ich mag alle sticky Artikel  anzeigen</h3>
<p>Selbstverständlich ist auch dies möglich. Dafür brauchts einen eigenen Loop und der sollte so anfangen.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">query_posts<span style="color: #009900;">&#40;</span><span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'post__in'</span><span style="color: #339933;">=&gt;</span>get_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sticky_posts'</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Dieser Code ist ein Zitat von <a href="http://wordpress.org/support/topic/208037?replies=5" title="Sticky Artikel Loop">Otto42</a>.</p>
<h3>Sticky Artikel aus der Anzeige unterhalb ausschließen</h3>
<p>Auch dafür braucht man einen eigenen Loop, die wichtigen Teile dafür sind dies:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">query_posts<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'caller_get_posts=1'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<h3> sticky Artikel verhindern oder das *sticky* entfernen</h3>
<p>Dafür muss man die functions.php öffnen und folgendes Hineintippen:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">update_option<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'sticky_posts'</span><span style="color: #339933;">,</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

<p>Allerdings gebe ich zu bedenken, dass dies zu Aufstand unter Autoren führen kann. Oder man bringt seinen Kunden zur Verzweiflung, weil der vielleicht was über sticky Artikel liest, aber selber sowas nicht kann. </p>
<div class="eyecatch">
<p>Achtung: Wie ich Neues zu sticky Artikel finde, ergänze ich diesen Artikel und gebe INFO via Kommentare. Daher wäre ein Kommentar-oder Feed Abo sehr gut, um am Laufenden zu bleiben.</p>
</div>
<div class="sign"> Weitersagen gerne erlaubt <img src="/wp-images/smilies/icon_confused.gif" alt="Kaffeetrinkender Smilie" width="27" height="21" /></div>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. Original article:  <a href="http://www.texto.de/wp-27-sticky-artikel-678/" >texto.de</a> (Digital Fingerprint:  textoakamts[texto.de])</small><hr />]]></content:encoded>
			<wfw:commentRss>http://www.texto.de/wp-27-sticky-artikel-678/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Loop Spielereien: Doppelte Artikel verhindern</title>
		<link>http://www.texto.de/loop-spielereien-doppelte-artikel-verhindern-660/</link>
		<comments>http://www.texto.de/loop-spielereien-doppelte-artikel-verhindern-660/#comments</comments>
		<pubDate>Tue, 04 Nov 2008 07:45:30 +0000</pubDate>
		<dc:creator>texto</dc:creator>
				<category><![CDATA[Tipps und Tricks]]></category>
		<category><![CDATA[loop]]></category>

		<guid isPermaLink="false">http://www.texto.de/?p=660</guid>
		<description><![CDATA[[gilt auch für WP 3.2.1 und höher]  WordPress Loop Spielerei, um doppelten Content einfach zu verhindern,  die Startseite oder WP das  CMS. Da 2 Artikel aus Kategorie 4, drüben 5 Artikeln aus Kategorie 6 und drunter einfach Artikel. Wie verhindert man, dass da die anderen Artikel nochmals angezeigt werden. Hier ein Tutorial.]]></description>
			<content:encoded><![CDATA[<dl class="left" style="width:190px;">
<dt> Loop &#8211; Filter-Artikel aussortieren</dt>
<dd><img src="http://www.texto.de/wp-images/1108/filtern.jpg" alt=" Mit WP Filter Artikel aussortieren" width="164" height="221" /></dd>
</dl>
<p> Du magst auf der Startseite aus ganz bestimmten Kategorien Artikel anzeigen und wiederum woanders einfach Artikel, aber eben nicht mehr aus diesen vorherigen Kategorien. Wie Du die jeweiligen Artikel dann anzeigst, also nur die Überschrift oder den Inhalt oder nur einen Auszug ist dann Geschmackssache.    Hier beschreibe ich wie Du das Template &#8211; also die index.php präparieren mußt, damit Dein Vorhaben gelingt.</p>
<p>Und dies könnte auch eine Antwort auf die Frage von karlkoch sein in <a href="http://www.texto.de/texto/wordpress-cms-homeseite-gestalten-praxisbeispiel/#comment-21870" title="Kommentar mit der Frage wie geht das?">einem der Kommentare </a>hier bei mir. <br class="clear"/></p>
<h3>Will man Artikel ausschließen dann filtert man diese am besten</h3>
<p>Du kannst Dir das ruhig wie bei jedem normalen Filter vorstellen. Die guten ins <span id="more-660"></span> Kröpfchen, die schlechten ins Töpfchen &#8230; oder so.</p>
<p>Also brauchts einen<strong> WP Filter</strong>, um dies umzusetzen. Hier gibt es genug davon:<a href="http://codex.wordpress.org/Plugin_API/Filter_Reference" title="WP Filter">WP Filter</a>  <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> .</p>
<p>Wir brauchen also einen Filter, der uns sagt &#8220;Wo ist denn der Artikel?&#8221; &#8211; mit ein wenig Englisch landet man dann ganz automatisch beim Richtigen:<strong>  posts_where</strong> <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  .</p>
<p>Dazu steht im Codex:</p>
<blockquote><p>
posts_where<br />
    applied to the WHERE clause of the query that returns the post array.<cite><a href="http://codex.wordpress.org/Plugin_API/Filter_Reference" title="WP Filter">Codex</a></cite></p>
</blockquote>
<p>Ganz frei und praktisch übersetzt: posts_where ist ein Filter, der es erlaubt in die Datenbankabfrage der Artikel einzugreifen. </p>
<p>Da nur die Artikel aus der Kategorie X,Y,Z da sein sollen und später nicht mehr da sein sollen, wollen wir eingreifen und dies geht mit einer Funktion am besten.  </p>
<p>post_strip ist ein frei gewählter Name!</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000000; font-weight: bold;">function</span> post_strip<span style="color: #009900;">&#40;</span><span style="color: #000088;">$where</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$myPosts</span><span style="color: #339933;">,</span> <span style="color: #000088;">$wpdb</span><span style="color: #339933;">;</span>
	<span style="color: #000088;">$where</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot; AND <span style="color: #006699; font-weight: bold;">$wpdb-&gt;posts</span>.ID not in(<span style="color: #006699; font-weight: bold;">$myPosts</span>) &quot;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">return</span> <span style="color: #000088;">$where</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span> <span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>Der 1. Loop Artikeln aus den Kategorien X,Y,Z</h3>
<p>In meinem Beispiel haben diese Kategorien die IDs 2,5,8 und es werden 5 Artikel angezeigt.</p>
<p>Bitte die überflüssigen Leerzeichen zwischen spitzer Klammer und Fragezeichen entfernen -Danke!</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000000; font-weight: bold;">global</span> <span style="color: #000088;">$myPosts</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$myPosts</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">''</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$my_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cat=2,5,8&amp;showposts=5'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>  
 <span style="color: #000088;">$myPosts</span> <span style="color: #339933;">.=</span> <span style="color: #000088;">$post</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">ID</span> <span style="color: #339933;">.</span> <span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;h2&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/h2&gt;
&lt;!-- alles was du anzeigen oder nicht anzeigen magst--&gt;
&lt; ?php endwhile; endif; ?&gt;
&lt;/div&gt;</pre></div></div>

<p>Zuerst sage ich WP, dass myPosts jetzt gilt &#8211; dann mache ich den Loop,also ich hole aus den Kategorien  2,5,8 insgesamt 5 Artikel, und teile WP mit, dass die Artikel ID (post ID) &#8220;meine Posts&#8221; also myPosts sind  <img src='http://www.texto.de/wp-includes/images/smilies/zwinker.gif' alt=':zwinker:' class='wp-smiley' />  .</p>
<h3>2. Loop einfach Artikel anzeigen, aber eben nicht die obigen ==> Filter !</h3>
<p>Zuerst sage ich WP, dass jetzt <strong>myPosts nicht mehr </strong>gilt, dann  füge  ich den Filter hinzu und gebe WP bekannt, dass der nach meinen Regeln filtern muß.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$myPosts</span> <span style="color: #339933;">.=</span> <span style="color: #0000ff;">&quot;0&quot;</span><span style="color: #339933;">;</span>  add_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_where'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_strip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>Jetzt kann ich einen ganz normalen Loop erstellen und WP macht &#8211; hoffentlich was ich will und zeigt alles an, aber nicht Artikel, die in obigen Kategorien bereits drin sind.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&lt;div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$my_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'showposts=5'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$my_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>? <span style="color: #339933;">&gt;</span>
<span style="color: #339933;">&lt;</span>h2<span style="color: #339933;">&gt;&lt;</span> ?php the_title<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> ? <span style="color: #339933;">&gt;&lt;/</span>h2<span style="color: #339933;">&gt;</span>
&nbsp;
<span style="color: #339933;">&lt;!--</span> alles was Du anzeigen magst<span style="color: #339933;">,</span> content  excerpt weiterblättern etc etc 
am besten im <span style="color: #b1b100;">default</span> theme anschauen was es da alles gibt <span style="color: #339933;">--&gt;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&lt;/div&gt;</pre></div></div>

<h3>Filter entfernen nicht vergessen </h3>
<p>Der hinzugefügte Filter wäre ewigst gültig, da das aber nicht sein sollte, ist es besser in wieder wegzunehmen, es erleichtert das Leben eindeutig:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"> <span style="color: #000000; font-weight: bold;">&lt;?php</span> remove_filter<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'posts_where'</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">'post_strip'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>Achtung: Hast Du in WP 2.7</h3>
<p> einen Artikel als &#8220;sticky&#8221; markiert, bleibt der da-logischerweise <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<h3>Fertig!</h3>
<p>War dies hilfreich, freu ich mich über einen Link, Social Bookmark und wenn Du weiter am Ball bleiben willst, abonnier einfach  das Feed  <img src='http://www.texto.de/wp-includes/images/smilies/zwinker.gif' alt=':zwinker:' class='wp-smiley' /> </p>
<div class="sign"> <img src="/wp-images/smilies/icon_confused.gif" alt="Kaffeetrinkender Smilie" width="27" height="21" /> bei Kaffee mag ich aber keine Filter &#8230;.</div>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. Original article:  <a href="http://www.texto.de/loop-spielereien-doppelte-artikel-verhindern-660/" >texto.de</a> (Digital Fingerprint:  textoakamts[texto.de])</small><hr />]]></content:encoded>
			<wfw:commentRss>http://www.texto.de/loop-spielereien-doppelte-artikel-verhindern-660/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Weiterblättern auf der statischen Seite oder Sidebar</title>
		<link>http://www.texto.de/weiterblaettern-auf-der-statischen-seite-oder-sidebar-621/</link>
		<comments>http://www.texto.de/weiterblaettern-auf-der-statischen-seite-oder-sidebar-621/#comments</comments>
		<pubDate>Thu, 21 Aug 2008 10:44:26 +0000</pubDate>
		<dc:creator>texto</dc:creator>
				<category><![CDATA[WP-CMS]]></category>
		<category><![CDATA[loop]]></category>
		<category><![CDATA[wordpress-cms]]></category>

		<guid isPermaLink="false">http://www.texto.de/texto/weiterblaettern-auf-der-statischen-seite-oder-sidebar/</guid>
		<description><![CDATA[Loop mit Pagination. Du magst auf einer statischen Seite oder in der Sidebar Artikel anzeigen und Du magst die vorherigen oder nächsten Artikeln - also das Weiterblättern-ebenfalls haben. Hier eine Lösung.]]></description>
			<content:encoded><![CDATA[<dl class="left" style="width:260px;">
<dt>WP Loop</dt>
<dd><img  src="http://www.texto.de/wp-images/loop-wordpress-mts.gif" alt="WordPress Loop in Action viele Beispiele" width="250" height="250" /></dd>
</dl>
<p><span class="caplize">V</span>italy hat <a href="http://www.texto.de/texto/wordpress-als-cms-printausgabe-statische-seite/#comment-21363" title="Vitalys Frage">eine Frage</a>: Auf der statischen Seite sollen 10 Artikel angezeigt werden und es sollte dann auch den Link &#8220;vorherige Beiträge&#8221; und &#8220;nächste Beiträge&#8221; geben. Es soll also das  Weiterblättern möglich sein. </p>
<p><strong>Erklärung für PHP Neulinge:</strong></p>
<p>Der Loop von WordPress holt aus der Datenbank Artikel mit allem was dazugehört. In den Tiefen der WP Dateien ist irgendwo definiert, dass es dabei eine &#8220;Weiterblättern&#8221; Funktion geben sollte und man kann im Admincenter festlegen nach wievielen Artikel diese WP anzeigt. </p>
<div class="eyecatch">
<p>Mag man jetzt einen eigenen Loop haben, weil man z.B.: auf einer statischen Seite/ oder in der Sidebar  Artikel anzeigen mag, die WP sonst nur auf der Startseite anzeigt, muß man WP diese &#8220;Weiterblättern&#8221; Funktion auch neu angeben.  </p>
</div>
<p>Man braucht also temporär (zeitlich und örtlich begrenzt) etwas <span id="more-621"></span>Neues. </p>
<p><strong>Erklärung für PHP Versteher:</strong></p>
<p>Next_posts_link und previous_posts_link nutzen wie vieles andere auch die globale Variabel $wp_query und die ist ein WP_Query object. Definiert man seinen eigenen wp_query hat man diese globale Variable $wp_query eben nicht mehr automatisch dabei und muß sie temporär neu angeben. </p>
<h3>Beispiel   für einen benutzerdefinierten Loop mit Weiterblättern</h3>
<p>Aus der Kategorie mit der ID 16 sollen 3 Artikeln angezeigt werden, gibt es mehr als 3 Artikeln, soll man den &#8220;ältere Artikel&#8221;-&#8221;neuere Artikel&#8221; Link sehen. </p>
<p>Und es ist völlig egal, ob dieser Loop in der Sidebar, vor einem normalen Loop, nach einem normalen Loop oder auf einer statischen Seite steht. Laut meinen Test funktioniert er immer.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span>
<span style="color: #000088;">$temp</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wp_query</span><span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wp_query</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> WP_Query<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">query</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'cat=16&amp;showposts=3'</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;paged='</span><span style="color: #339933;">.</span><span style="color: #000088;">$paged</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span>
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">have_posts</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">the_post</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
Die Ausgabe der Artikel
&nbsp;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #b1b100;">endwhile</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>
&nbsp;
&nbsp;
&lt;div class=&quot;navigation&quot;&gt;
 &lt;div class=&quot;alignleft&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> next_posts_link<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'&amp;laquo; &amp;auml;ltere Artikel'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/div&gt;
  &lt;div class=&quot;alignright&quot;&gt;<span style="color: #000000; font-weight: bold;">&lt;?php</span> previous_posts_link<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'neuere Artikel &amp;raquo;'</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">?&gt;</span>&lt;/div&gt;
&nbsp;
&lt;/div&gt;
<span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$wp_query</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #000088;">$wp_query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$temp</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>Erklärung zum Code</h3>
<p>Mit</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000088;">$temp</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$wp_query</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$wp_query</span><span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span></pre></div></div>

<p>sagt man zu WP: Du liebes WordPress, ich nutz jetzt diese globale Variable ($wp_query) mal eine zeitlang ($temp) so wie ich es will ($wp_query  null) (und nicht wie von den WP Programmiern vorgegeben) <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' /> </p>
<p>Man reißt also kurzfristig die Macht über eine wichtige Variable an sich. </p>
<p>Damit WordPress nachher wieder wie gewohnt seinen Dienst macht, muß man ihm diese Macht über diese $wp_query Variable wieder zurückgeben.</p>
<p>Dies geht damit:</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">&lt;?php</span> <span style="color: #000088;">$wp_query</span> <span style="color: #339933;">=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #000088;">$wp_query</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$temp</span><span style="color: #339933;">;</span><span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<h3>Fragen dazu? </h3>
<div class="sign">Weitersagen gerne erlaubt. Wars hilfreich freu ich mich über einen Link oder social Bookmark <img src='http://www.texto.de/wp-includes/images/smilies/icon_wink.gif' alt=';)' class='wp-smiley' />  </div>
<hr /><small>Copyright &copy; 2011<br /> This feed is for personal, non-commercial use only. <br /> The use of this feed on other websites breaches copyright. If this content is not in your news reader, it makes the page you are viewing an infringement of the copyright. Original article:  <a href="http://www.texto.de/weiterblaettern-auf-der-statischen-seite-oder-sidebar-621/" >texto.de</a> (Digital Fingerprint:  textoakamts[texto.de])</small><hr />]]></content:encoded>
			<wfw:commentRss>http://www.texto.de/weiterblaettern-auf-der-statischen-seite-oder-sidebar-621/feed/</wfw:commentRss>
		<slash:comments>24</slash:comments>
		</item>
	</channel>
</rss>

