Current location: Hot Scripts Forums » Programming Languages » PHP » Proper Code for Wordpress


Proper Code for Wordpress

Reply
  #1 (permalink)  
Old 11-11-09, 09:18 AM
jduvall1 jduvall1 is offline
New Member
 
Join Date: Nov 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Proper Code for Wordpress

For some reason this will not work when I place it into my sidebar. I have copied it directly from the CODEX. Does anyone have any suggestions? Thanks

As an alternative, this code in the sidebar.php, displays only top level Pages, but when viewing a Page that has children (or is a child) it displays only children of that parent.

When visiting main page, all top level pages are listed in the sidebar.
When visiting a top level page with no children, all top level pages are listed.
When visiting a top level page with children, just the children pages, and descendant pages, are listed.
When visiting a child page, just the children, and descendant pages, of that parent, are listed.

<ul role="navigation">
<?php
$output = wp_list_pages ( 'echo = 0 &depth = 1 &title_li = <h2> Top Level Pages </ h2>');
if (is_page ()) (
$page = $post-> ID;
if ($post-> post_parent) (
$page = $post-> post_parent;
)
$children = wp_list_pages ( 'echo = 0 &child_of ='. $page. '&title_li =');
if ($children) (
$output = wp_list_pages ( 'echo = 0 &child_of ='. $page. '&title_li = <h2> Child Pages </ h2>');
)
)
echo $output;?>
</ul>
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
  #2 (permalink)  
Old 11-12-09, 06:38 PM
pyr0t3chnician pyr0t3chnician is offline
Newbie Coder
 
Join Date: Jul 2009
Posts: 30
Thanks: 0
Thanked 1 Time in 1 Post
A couple things I noticed here and comparing to the CODEX page you referenced.

In the reference page, they use { and } and here I see ( and ) instead.

Also I notice spaces in the inside of the wp_list_pages function call:
'echo = 0 &child_of ='.$page... etc
where it shows no spaces on the reference page. That could be causing a glitch.

Try fixing that.... or copying and pasting your code using the code button in the text box.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiShare on FacebookShare on Stumble UponShare on Twitter
Reply With Quote
Reply

Bookmarks

Tags
wordpress proper code


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Match code in link with code with one in file and extract line peuplarchie PHP 3 10-24-09 02:23 AM
Freeze columns in a table Rita Negi Script Requests 1 09-01-09 09:23 AM
OTO Redirect Code Placement Tony S. HTML/XHTML/XML 7 07-25-09 10:31 AM
Need captcha for html+php contact form sujata_ghosh PHP 6 03-22-09 04:46 PM
Explanation of Code... Please davidk19380 Perl 1 02-26-06 02:50 PM


All times are GMT -5. The time now is 10:12 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.