Display list of wordpress pages in two columns

November 28, 2009

Usually in WordPress, the following code is used to call the pages list (you can find it in one of the sidebar files): <?php wp_list_pages(); ?> Normally when the list of pages is displayed in the sidebar or on any part of the theme, it displays in a single column. Through the following hack, you can split your pages list evenly into two or more columns which can save space and not make your pages longer. Now, we will try and split the pages into two columns. Simply paste the following code where you’d like your... [Read the full story]

create wordpress page template to redirect to first child page

June 9, 2009

Many WordPress users uses parent pages and subpages to order the informations displayed on their blogs. Then how to be able to redirect to the first child page if the current page have children pages? You have to create a wordpress page template to redirect to first child page, Create a new file and paste the following code in it:   <?php /* Template Name: Redirect To First Child */ if (have_posts()) {   while (have_posts()) {     the_post();     $pagekids = get_pages("child_of=".$post->ID."&sort_column=menu_order");    ... [Read the full story]

Include external pages in WordPress navigation

January 28, 2009

Imagine that you’re running a blog, but also have an online shop, a forum and some static pages. Do you’d like to be able to include theses pages in WordPress navigation? If yes, just read on. The solution to this problem is fairly simple. As the wp_list_pages() function returns only <li>…</li> elements, we just have to add static links to our external pages, just as shown below: <ul> <?php wp_list_pages('title_li='); ?> <li><a href="forum.php">Forum</a></li> <li><a... [Read the full story]

Use a custom blurb when listing wordpress pages

January 18, 2009

How to get a list of pages along with a custom key from each page, used to create a description? The first thing to do is to paste the following code where you want your pages to be listed. It can be your sidebar, or a page template, for exemple. <?php $pages = get_pages(); foreach($pages as $page) { $custom_blurb = get_post_meta($page->ID, 'custom_blurb', true); echo "<h3><a href=\"".get_page_link($page->ID)."\">$page->post_title</a></h3>"; echo $custom_blurb; } ?> Once... [Read the full story]

Adding A Private Page Into The Navigation menu

January 11, 2009

If you use pages which have the state private, they will not be shown in the navigation. Nevertheless it can make sense to show this specific page in the navigation, if you want to provide easy access to this page for your users. The page should only appear to privileged users for sure. I will show you a little hack, which will let you exactly do this. simply open the file where your navigation is (You can look up for the wp_list_pages() function) and insert this snippets instead of the function: <ul> <?php wp_list_pages('depth=1&title_li=0&sort_column=menu_order'); if(current_user_can('read_private_pages'))... [Read the full story]