<?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>WP Engineer &#187; List Pages</title>
	<atom:link href="http://wpengineer.com/tag/list-pages/feed/" rel="self" type="application/rss+xml" />
	<link>http://wpengineer.com</link>
	<description>WordPress News, Hacks, Tips, Tutorials, Plugins and Themes</description>
	<lastBuildDate>Mon, 21 May 2012 22:48:48 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Add Links To WordPress List Pages</title>
		<link>http://wpengineer.com/888/add-links-to-wordpress-list-pages/</link>
		<comments>http://wpengineer.com/888/add-links-to-wordpress-list-pages/#comments</comments>
		<pubDate>Tue, 10 Mar 2009 19:07:49 +0000</pubDate>
		<dc:creator>Frank</dc:creator>
				<category><![CDATA[WPengineer Misc]]></category>
		<category><![CDATA[List Pages]]></category>
		<category><![CDATA[WordPress]]></category>

		<guid isPermaLink="false">http://wpengineer.com/?p=888</guid>
		<description><![CDATA[Not infrequently, the menus on blogs, created with WordPress, having static links. This may initially seem easier and less trouble, but if changes or maintenance by users who have no knowledge or access to the templates occur, it is cumbersome and error prone. Therefore I prefer to use the necessary template tags and using the [...]]]></description>
			<content:encoded><![CDATA[<p>Not infrequently, the menus on blogs, created with WordPress,  having static links. This may initially seem easier and less trouble, but if changes or maintenance by users who have no knowledge or access to the templates occur, it is cumbersome and error prone. Therefore I prefer to use the necessary template tags and using the help of parameters that are not desirable (<code>exclude</code>) or desired (<code>include</code>) pages load. In addition, you can add content via the Hook, which I will explain briefly.</p>
<p><span id="more-888"></span><br />
Like many features of WordPress, you can also use a filter hook for <code>wp_list_pages()</code>. The function itself has a <a href="http://codex.wordpress.org/Template_Tags/wp_list_pages">detailed description in the Codex</a>.</p>
<pre lang="php">
$output = apply_filters(&#039;wp_list_pages&#039;, $output);
</pre>
<p>Let's use this advantage and expand the content of two sample links that are otherwise manually added in the theme. We place the following code snippet into the <code>functions.php</code> of the theme. The tags need to be passed as the hook is integrated after the list.</p>
<pre lang="php">
if ( !function_exists(&#039;fb_add_page_link&#039;) ) {
	function fb_add_page_link($output) {
		$output .= &#039;&lt;li&gt;&lt;a href=&quot;http://example.com/1/&quot;&gt;Example 1&lt;/a&gt;&lt;/li&gt;&#039;;
		$output .= &#039;&lt;li&gt;&lt;a href=&quot;http://example.com/2/&quot;&gt;&lt;span&gt;Example&lt;/span&gt; 2&lt;/a&gt;&lt;/li&gt;&#039;;

		return $output;
	}

	add_filter(&#039;wp_list_pages&#039;, &#039;fb_add_page_link&#039;);
}
</pre>
<p>Now the output will be added to the two example links. The following HTML syntax should explain it.</p>
<pre lang="html4strict">
&lt;li class=&quot;pagenav&quot;&gt;
	&lt;h3&gt;Pages&lt;/h3&gt;
	&lt;ul&gt;
		&lt;li class=&quot;page_item page-item-2&quot;&gt;&lt;a href=&quot;http://example.com/?page_id=2&quot; title=&quot;About&quot;&gt;About&lt;/a&gt;&lt;/li&gt;
		&lt;li class=&quot;page_item page-item-64&quot;&gt;&lt;a href=&quot;http://example.com/?page_id=64&quot; title=&quot;Default Form&quot;&gt;Default Form&lt;/a&gt;&lt;/li&gt;
		&lt;li class=&quot;page_item page-item-40&quot;&gt;&lt;a href=&quot;http://example.com/?page_id=40&quot; title=&quot;Offerings&quot;&gt;Offerings&lt;/a&gt;&lt;/li&gt;
		&lt;li class=&quot;page_item page-item-12&quot;&gt;&lt;a href=&quot;http://example.com/?page_id=12&quot; title=&quot;Page 2&quot;&gt;Page 2&lt;/a&gt;
			&lt;ul&gt;
				&lt;li class=&quot;page_item page-item-14&quot;&gt;&lt;a href=&quot;http://example.com/?page_id=14&quot; title=&quot;Subpage&quot;&gt;Subpage&lt;/a&gt;
					&lt;ul&gt;
						&lt;li class=&quot;page_item page-item-45&quot;&gt;&lt;a href=&quot;http://example.com/?page_id=45&quot; title=&quot;Subsubpage&quot;&gt;Subsubpage&lt;/a&gt;&lt;/li&gt;
					&lt;/ul&gt;
				&lt;/li&gt;
			&lt;/ul&gt;
		&lt;/li&gt;
		&lt;li class=&quot;page_item page-item-16&quot;&gt;&lt;a href=&quot;http://example.com/?page_id=16&quot; title=&quot;Page 3&quot;&gt;Page 3&lt;/a&gt;&lt;/li&gt;
	&lt;/ul&gt;
&lt;/li&gt;

&lt;li&gt;&lt;a href=&quot;http://example.com/1/&quot;&gt;Example 1&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;http://example.com/2/&quot;&gt;&lt;span&gt;Example&lt;/span&gt; 2&lt;/a&gt;&lt;/li&gt;
</pre>
<p>Be careful, these links will be added after a check of the parameters and are therefore no longer able to be removed with the help of the parameter. Assuming you use the template tag <code>wp_list_pages()</code> several times with different output, there will be for all the expansion included. Differences can not easily be made. Not even with the second template tag for pages <code>wp_page_menu()</code>. This template tag drags the content of the function <code>wp_list_pages()</code>!</p>
<p>As an indication it should be mentioned that the template tag <code>wp_page_menu()</code> can be used only since WordPress version 2.7. This tag may in fact can not much more, except automatic adding a Home link and the control of the output (<code>echo</code>), more in <a href="http://codex.wordpress.org/Template_Tags/wp_page_menu">description</a>. But the function differentiate still in two other cases so you can hook in at two points via the filter hook and modify.<br />
For one, you can extend the arguments ...</p>
<pre lang="php">
$args = apply_filters( &#039;wp_page_menu_args&#039;, $args );
</pre>
<p>... and on the other hand you can extend the menu.</p>
<pre lang="php">
$menu = apply_filters( &#039;wp_page_menu&#039;, $menu, $args );
</pre>
<p>And so you can once again realize different outputs. The following syntax calls the example links in the latter function <code> wp_page_menu()</code>, and thus manages <code>wp_list_pages()</code> without the extension of the two links.</p>
<pre lang="php">
add_filter(&#039;wp_page_menu&#039;, &#039;fb_add_page_link&#039;);
</pre>
<p>With a little reflection you can be quite flexible to configure output and the authors can participate when it comes to automatically add pages to navigations.</p>
<p><cite>I have noticed the idea at <a href="http://sivel.net/2009/03/adding-additional-links-to-the-output-from-wp_list_pages/">Sivel.net</a></cite><br />
<hr /><a href="http://wpplugins.com/plugin/281/snippets" title="More informations about this plugin for WordPress"><img src="http://wpengineer.com/wp-content/themes/wpe-3/images/snippets-125-125.png" height="90" alt="WordPress Snippet Plugin" /></a> <a href="http://xtreme-theme.com"><img src="http://wpengineer.com/wp-content/uploads/feed-banner-2.jpg" alt="Xtreme One WordPress Framework"/></a><br />
&copy; <a href="http://wpengineer.com/">WP Engineer Team</a>, All rights reserved <small>(Digital Fingerprint: WPEngineer-be0254ce2b4972feb4b9cb72034a092d)</small></p>
]]></content:encoded>
			<wfw:commentRss>http://wpengineer.com/888/add-links-to-wordpress-list-pages/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
	</channel>
</rss>

