Work in progress
<?php include 'key_parts/query-control.php'; //This block of code gets the titles from the pages they are linked to ?>
<?php
/*
Template Name: Procedures Archive
*/
add_filter( 'post_class', 'be_archive_post_class' ); //Make the view for this page broken into 3 sections
// This will trigger if I turn the checkbox as on in the head options area
if (get_field('display_alt_procedure_page' , 'option') ) {
//add css to procedure page only when the alt version is checked
add_action( 'wp_enqueue_scripts', 'enterprise_load_scripts_query' );
function enterprise_load_scripts_query() {
wp_enqueue_style( 'nuvo-query-css', get_bloginfo( 'stylesheet_directory' ) . '/css/query.css', '', '');
}
add_action( 'genesis_before_loop', 'nuvo_check_for_terms' );
function nuvo_check_for_terms() {
$taxonomy_name = 'procedure-types'; //specify your custom taxonomy here
// Retrieve the terms in the above custom taxonomy
$tax_terms = get_terms( $taxonomy_name );
// if there's at least 1 taxonomy term, then replace the default loop with a custom one
if ( ! empty( $tax_terms ) && ! is_wp_error( $tax_terms ) ) {
remove_action( 'genesis_loop', 'genesis_do_loop' );
add_action( 'genesis_loop', 'nuvo_do_loop' );
}
}
remove_filter( 'post_class', 'be_archive_post_class' ); //Make the view for this page fullscreen
function nuvo_do_loop() {
$taxonomy_name = 'procedure-types'; //specify your custom taxonomy here
$get_terms = get_terms( $taxonomy_name );
$keyid = get_field('order', $get_term); //New / working on
$key = array('key' => 'order_in_archive', 'value' => $keyid) ;
foreach( $get_terms as $get_term ) {
echo $get_term;
}
// Retrieve the terms in the above custom taxonomy
$tax_terms = get_terms( $taxonomy_name , 'order=DESC&orderby=meta_value_num&meta_query=' . $key );
echo '<div class="posts-list">';
foreach( $tax_terms as $tax_term ) {
echo '<article >';
echo '<h2 class=" primary_color">' . $tax_term->name . '</h2>';
$args = array(
'tax_query' => array(
array(
'taxonomy' => $taxonomy_name,
'field' => 'slug',
'terms' => array( $tax_term->slug )
)
),
// 'posts_per_page' => 3,
//'order' => 'DESC',
//'meta_key' => '$key', //New / working on
);
$query = new WP_Query( $args );
echo '<ul>';
while ( $query->have_posts() ) {
$query->the_post();
echo '<article class="post-142 procedure type-procedure status-publish format-standard has-post-thumbnail procedure-types-head entry secondary_color">';
echo '<li><h2 class="entry-title"><a href="' . get_permalink() . '">'. get_the_title() .'</a></h2></li>';
echo '</article>';
}
echo '</ul>';
wp_reset_query();
echo '</article>';
} // end foreach
echo '</div>';
}
}
// Add Sidebar with Menu just for this page type
add_action( 'genesis_before_sidebar_widget_area', 'nuvo_get_menu' );
function nuvo_get_menu() {
get_menu("Procedures");
}
//The logic behind how we pick what thumbnail to use
add_action( 'genesis_entry_content', 'nuvo_display_url_field_procedure' );
function nuvo_display_url_field_procedure() {
display_url_field_procedure( get_permalink() , get_the_title() , get_post_meta( get_the_ID(), 'procedure_icon', true ) );
}
//* Remove the link from each post title
add_action( 'genesis_post_title_output', 'nuvo_post_title_output', 15 );
//* Run the Genesis loop
genesis();