• Resolved Luiguis

    (@luiguis)


    For example i have a page gallery and other portfolio, these use a page template template-gallery.php, i want to get all the permalinks of pages than use these template, in my example i get the permalink of gallery and portfiolio, i know is posible if your are in the page using http://codex.wordpress.org/Function_Reference/is_page_template but how can is get it from a function in functions.php or other file.
    Thanks

Viewing 1 replies (of 1 total)
  • <?php
    $meta_key = '_wp_page_template';
    $template = $wpdb->get_var( $wpdb->prepare("SELECT meta_value FROM $wpdb->postmeta WHERE meta_key = %s AND post_id = %d", $meta_key, $post->ID) );
    $template_pages = $wpdb->get_col( $wpdb->prepare("SELECT post_id FROM $wpdb->postmeta WHERE meta_key = %s AND meta_value = %s", $meta_key, $template) );
    wp_list_pages('include=' .implode(",", $template_pages));
    ?>
Viewing 1 replies (of 1 total)
  • The topic ‘how to select pages with specific page template?’ is closed to new replies.