Devam Ediyor

Fix Simple PHP Wordpress Page Depth Function

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.

Beceriler: PHP, WordPress

Daha fazlasını görün: wordpress get_pages depth, wordpress page depth, get_pages depth, wordpress pages depth, php pg, li.be, li-be, depth first, page depth wordpress, get_pages wordpress depth, get_post_ancestors get_pages, wordpress depth php, simple function php wordpress, find page depth wordpress, php page depth, wordpress list pages depth, wordpress page, wordpress basic, PHP WORDPRESS, php function , php / wordpress, php -wordpress, pg, desc, simple continue

İşveren Hakkında:
( 7 değerlendirme ) Alexandria, Australia

Proje NO: #693599

Seçilen:

Freqsoft

Ready to start. Check PM :)

1 gün içinde 30$ USD
(3 Değerlendirme)
2.7

2 freelancer bu iş için ortalamada 30$ teklif veriyor

urmi1

let's start please see PMB for more details...

in 0 gün içinde30$ USD
(82 Değerlendirme)
5.8