Skip to content

Instantly share code, notes, and snippets.

@yavallejo
Created August 3, 2017 16:47
Show Gist options
  • Save yavallejo/cde2fdc21bda6fe556e843dca46c77c4 to your computer and use it in GitHub Desktop.
Save yavallejo/cde2fdc21bda6fe556e843dca46c77c4 to your computer and use it in GitHub Desktop.
Listamos las paginas que han seleccionado la plantilla salud (solo es cambiar el parámetro del meta_value por el nombre que ustedes han seleccionado)
<div id="sidebar1" class="sidebar hide-for-small-only hide-for-medium-only hide-for-large-only xlarge-4 columns" role="complementary">
<div class="row">
<div class="widget margin-top background--box">
<h2 class="title title--section title--section--min">Salud</h2>
<ul class="menu vertical">
<?php
$args = array(
'post_type' => 'page',
'order' => 'ASC',
'posts_per_page' => -1,
'meta_key' => '_wp_page_template',
'meta_value' => 'template-salud.php'
);
$page_template_query = new WP_Query($args);
if(!empty($page_template_query->posts))
{
foreach($page_template_query->posts as $page){
?>
<li>
<a href="<?php echo $page->guid ?>" title="<?php echo $page->post_title ?>"><?php echo $page->post_title ?></a>
</li>
<?php
}
}
?>
</ul>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment