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

Thil87 on "[Plugin: Polylang] Get_pages array shows default language"

$
0
0

I tweaked the get_pages example code on wordpress.org to show the title, page_link and some custom fields of a childpage on the homepage, but the code only returns the content of the default language. I would like the code to retrieve the content of the current language.

<ul id="latest">
			 <?php
				$mypages = get_pages( array( 'child_of' => 23, 'sort_column' => 'menu_order', 'number' => '1', 'offset' => '0', 'sort_order' => 'asc' ) );

				foreach( $mypages as $page ) {
					$content = $page->post_content;
					if ( ! $content ) // Check for empty page
						continue;

					$content = apply_filters( 'the_content', $content );
				?>

				<li id="latest" style="background: <?php the_field('kleurcode_project', $page->ID); ?>;">

					<h2><a href="<?php echo get_page_link( $page->ID ); ?>" style="color:<?php the_field('kleurcode_tekst', $page->ID); ?>"><?php echo $page->post_title; ?></a></h2>

					<p><a href="<?php echo get_page_link( $page->ID ); ?>" style="color:<?php the_field('kleurcode_tekst', $page->ID); ?>"><?php the_field('short_text', $page->ID); ?></a></p>

					<a href="<?php echo get_page_link( $page->ID ); ?>"><img src="<?php the_field('featured_image', $page->ID); ?>"></a>

				</li>
				<?php
				}
			?>

			</ul>

I couldn't find an answer to this question on the forums, I would surely appreciate getting to know the solution.

http://wordpress.org/plugins/polylang/


Viewing all articles
Browse latest Browse all 11471

Trending Articles



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