Quantcast
Channel: polylang – WordPress.org Forums
Viewing all articles
Browse latest Browse all 11471

elviselvis on "List parent Page and all descendant Pages with Polylang plugin"

$
0
0

Hello, I have a multilingual website which uses Polylang plugin.
I found this code which uses wp_list_pages to display parent and all child pages, but when I'm changing the language, list of pages is still in default language. What I need is, modify this code, that when I'm changing the languge, it will display the translated list of pages or if no translation is avalible, then the default one.
Here is the original code.

<?php
$parent = 93;
$args=array(
  'child_of' => $parent
);
$pages = get_pages($args);
if ($pages) {
  $pageids = array();
  foreach ($pages as $page) {
    $pageids[]= $page->ID;
  }

  $args=array(
    'title_li' => 'Tree of Parent Page ' . $parent,
    'include' =>  $parent . ',' . implode(",", $pageids)
  );
  wp_list_pages($args);
}
?>

Could someone help me please?


Viewing all articles
Browse latest Browse all 11471

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>