Two hacks about WordPress

  • To exclude page links in the navigation bar in the header.
    I have some pages that I want them to be accessible by the public but not listed in the navigation bar. After some search, I found this effective yet simple solution. What I did is to edit the header.php file in the current theme folder. Locate the function wp_list_pages and add exclude=pageID#,pageID# to its arguments, where pageID#s are the ID numbers of the pages to be hidden. Here is an example:

    <?php wp_list_pages('exclude=123&sort_column=menu_order&depth=1&title_li='); ?>

    where 123 is the ID of the page to be hidden.

    UPDATE: Just found a nice plugin, Page Link Manager, that does the same job in a much neater manner. Besides the option page, an “Include Page in Site Navigation” checkbox will be available when a page is being edited.

  • To exclude pages from the Extended Live Archive.
    I just installed this plugin to display the blog archives. It works very well in a very neat and intuitive way. But I found that it also includes pages by default and I couldn’t find the option to disable it. So I searched again and found a solution in their Flickr forum. What should be edited are two files in the plugin folder: af-extended-live-archive.php and af-extended-live-archive-include.php.
    In these two files, locate the following two expressions in both files

    post_status = 'publish'
    p.post_status = 'publish'

    then change them to

    post_status = 'publish' AND post_type='post'
    p.post_status = 'publish' AND p.post_type='post'

    respectively. That’s it. Now ELA displays posts only.

Related posts

Leave a comment


Leave a Reply

[ Ctrl + Enter ]