Skip to content

Instantly share code, notes, and snippets.

@QROkes
Created March 6, 2016 01:50
Show Gist options
  • Save QROkes/17c9588713895bafa072 to your computer and use it in GitHub Desktop.
Save QROkes/17c9588713895bafa072 to your computer and use it in GitHub Desktop.
Multilingual archive sitemap template (WordPress + Genesis Framework + Poylang)
<?php
/**
* Genesis Framework
* Multilingual archive sitemap template (page_archive.php)
**/
//* Template Name: Archive
// Remove standard post content output
remove_action( 'genesis_post_content', 'genesis_do_post_content' );
remove_action( 'genesis_entry_content', 'genesis_do_post_content' );
// Add new multilingual content (Polylang Plugin)
add_action( 'genesis_entry_content', 'qr_archive_sitemap_multilingual' );
add_action( 'genesis_post_content', 'qr_archive_sitemap_multilingual' );
function qr_archive_sitemap_multilingual() { ?>
<h4><?php _e( 'Páginas / Pages' ); ?></h4>
<ul><?php _e( '<h6>Español:</h6>' ); ?>
<?php wp_list_pages( 'title_li=&lang=es' ); ?>
</ul>
<ul><?php _e( '<h6>English:</h6>' ); ?>
<?php wp_list_pages( 'title_li=&lang=en' ); ?>
</ul>
<h4><?php _e( 'Categorías / Categories' ); ?></h4>
<ul><?php _e( '<h6>Español:</h6>' ); ?>
<?php wp_list_categories( 'sort_column=name&title_li=&lang=es' ); ?>
</ul>
<ul><?php _e( '<h6>English:</h6>' ); ?>
<?php wp_list_categories( 'sort_column=name&title_li=&lang=en' ); ?>
</ul>
<h4><?php _e( 'Publicaciones recientes / Recent Posts' ); ?></h4>
<ul><?php _e( '<h6>Español:</h6>' ); ?>
<?php
global $post;
$myposts = get_posts(array(
'posts_per_page' => 1000,
'lang' => 'es' // use language slug in the query
));
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach;
wp_reset_postdata();?>
</ul>
<ul><?php _e( '<h6>English:</h6>' ); ?>
<?php
$myposts = get_posts(array(
'posts_per_page' => 1000,
'lang' => 'en' // use language slug in the query
));
foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach;
wp_reset_postdata();?>
</ul>
<?php
}
genesis();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment