Find Jobs
Hire Freelancers

Fix Simple PHP Wordpress Page Depth Function

$30-250 USD

In Progress
Posted almost 14 years ago

$30-250 USD

Paid on delivery
I have created a php function to expand upon the basic wp_list_pages function. But to do it I needed to find out a pages depth, I figured out how to do it on a single page, but when I send it do the custom list pages function it just returns zero for the pages being sent to it. I use this within the wordpress page: listpages($post); And these functions function pagedepth($page) { $ancestors = get_post_ancestors($page->ID); return count($ancestors); } function listpoint($pg) { echo '<li><a href="'; echo get_page_link($pg->ID); echo '">'; echo $pg->post_title; echo '</a><small> '; echo get_userdata($pg->post_author)->display_name; echo '&#151;'; if (get_post_custom_values('Character', $pg->ID)==TRUE) { $mykey_values = get_post_custom_values('Character', $pg->ID); foreach ( $mykey_values as $key => $value ) { echo $value; echo ', '; } } echo mysql2date('D, M j, Y H:i a', $pg->post_date); echo '</small></li>'; } function listpages($thepost) { echo '<ul>'; $pages = get_pages('child_of='.$thepost->ID.'&sort_column=post_date&sort_order=DESC'); $previousdepth = 0; $homedepth = pagedepth($thepost); foreach($pages as $page) { $pagedepth = pagedepth($page); if($pagedepth > $previousdepth) echo '<ul>'; while($pagedepth < $previousdepth && count(get_pages('child_of='.$page->ID)) != 0) { echo '</ul>'; $pagedepth--; if($pagedepth == 1) break; } $parent_page = $page->post_parent; $content = $page->post_content; if(!$content) continue; $content = apply_filters('the_content', $content); listpoint($page); $previousdepth = $pagedepth; } } First solution gets paid $30 immediately. If done well and good I there will be more work down the track.
Project ID: 693599

About the project

1 proposal
Remote project
Active 14 yrs ago

Looking to make some money?

Benefits of bidding on Freelancer

Set your budget and timeframe
Get paid for your work
Outline your proposal
It's free to sign up and bid on jobs
1 freelancer is bidding on average $30 USD for this job
User Avatar
let's start please see PMB for more details...
$30 USD in 0 day
4.9 (233 reviews)
7.3
7.3

About the client

Flag of AUSTRALIA
Lane Cove North, Australia
5.0
7
Payment method verified
Member since Nov 16, 2009

Client Verification

Thanks! We’ve emailed you a link to claim your free credit.
Something went wrong while sending your email. Please try again.
Registered Users Total Jobs Posted
Freelancer ® is a registered Trademark of Freelancer Technology Pty Limited (ACN 142 189 759)
Copyright © 2024 Freelancer Technology Pty Limited (ACN 142 189 759)
Loading preview
Permission granted for Geolocation.
Your login session has expired and you have been logged out. Please log in again.