Forums

Using blogtitle() in wp_list_pages as title_li (5 posts)

  1. walkingpig
    Member
    Posted 3 years ago #

    Hi all,

    I use wordpress to run a niche website i made, i use pages not posts for various reasons. My left menu prints out all pages, using wp_list_pages(), i specify a variable title_li in that function call. As follows:

    <?php wp_list_pages('title_li=<h2>Color Blindness</h2>' ); ?>

    This of course outputs correctly, as follows in the html source output:
    <div id="sidebar_left">

    <li class="pagenav"><h2>Color Blindness</h2>
    <?php wp_list_pages("title_li=<h2>" . bloginfo('name') . "</h2>" ); ?>

    This outputs the blog name BEFORE the source its enclosed in:
    <div id="sidebar_left">

    Color Blindness<li class="pagenav"><h2></h2>
    Can anyone explain why, and how to get the latter to output its return value where it should? I want to recycle the theme on a new site and like to fix any manual things in the theme like this as i find/realise:)

    Charles

  2. blondishnet
    Member
    Posted 3 years ago #

    This is what I use. If you have specified in your WordPress admin panel that you have put a certain page as your home page, your site should direct to that page.

    <ul>
    			<li class="page_item" id="first"><a href="<?php bloginfo('url'); ?>">Home</a></li> 		<?php wp_list_pages('title_li=&depth=1'); ?>
    		</ul>

    I hope this code can help you as I use it on my own. I do see some differences from what you have even for it being in your sidebar.

    You should be able to widgetize your sidebar and include pages.

  3. walkingpig
    Member
    Posted 3 years ago #

    Hi,

    Good advice, having read the wp_list_pages entry in hte codex, it claims i can specify to have no title, this way i can use code similar to yours above the function call. I tried this today, but hadn't read the codex and kept ending up with some sort of default pages title instead of nothing at all, combining your advice with the codex' knowledge should provide a solution:)

    I really dont know much about widgets, i should do some reading (by that i mean, i know nothing!) my next goal is to be able to slot an adsense linkuit into the output of wp_list_pages(), after the end of the first Parent and all its children - not looking easy - since the theme is to be recycled on many pages with varying quantities of parents and children.

    Charles

  4. blondishnet
    Member
    Posted 3 years ago #

    Trust me, widgetizing your templates will save you time in the long run, especially if you decide months down the line to change your layout.

  5. walkingpig
    Member
    Posted 3 years ago #

    Hi,

    used your example and its all working now - thanks. I'm reading more about these widgets as per your advice!

    Charles

Topic Closed

This topic has been closed to new replies.

About this Topic