<commit_before><?php
/**
 * The template for displaying Archive pages.
 *
 * Used to display archive-type pages if nothing more specific matches a query.
 * For example, puts together date-based pages if no date.php file exists.
 *
 * If you'd like to further customize these archive views, you may create a
 * new template file for each specific one. For example, Twenty Twelve already
 * has tag.php for Tag archives, category.php for Category archives, and
 * author.php for Author archives.
 *
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 */

get_header(); ?>

<?php
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;

/* HOW TO SORT */

// These are the default options
// correspond to url /production/

$args = array(  'posts_per_page' => 12, 
                'paged' => $page,
                'post_type' => 'production',
                'orderby' => 'meta_value',
                'meta_key' => '<KEY>',
                'order' => 'DESC');

/*  We allow to specify a different order through the url, i.e.
 *
 *  /production/?order=ASC
 */

if (array_key_exists('order', $_GET))  {
    $args['order'] = $_GET['order'];
}

/*  We also allow to specify a different column to order by,
 *  and in case of ordering by a meta value, which one:
 * 
 *  /production/?orderby=title
 *  /production/?orderby=title&order=ASC
 *  /production/?orderby=meta_value&meta_key=wpcf-genre&order=ASC
 *
 */
 
if ( array_key_exists('orderby', $_GET) )  {
    $args['orderby'] = $_GET['orderby'];
    if ( $_GET['orderby'] == 'meta_value' && array_key_exists('meta_key', $_GET))  {
        $args['meta_key'] = $_GET['meta_key'];
    }
}

if ($args['orderby'] != 'meta_value') {
    unset( $args['meta_key'] );
}

query_posts($args);


/* HOW TO DISPLAY */

$format = 'detail';

if ( array_key_exists('format', $_GET) )  {
    $format = $_GET['format'];
}
function get_the_production_uri($args=array()) {
    global $format;
    if ( !get_option( "permalink_structure" ) ) {
        // uri starts with /?post_type=production&
        $args = array('post_type' => 'production') + $args;
    }
    if (!array_key_exists('format', $args))  {
        $args['format'] = $format;
    }
    $qstring = http_build_query($args);
    if ($qstring) {
        $qstring = '?' . $qstring;
    }
    $folder = '';
    if ( get_option( "permalink_structure" ) ) {
        // uri starts with /?post_type=production&
        $folder = 'production/';
    }

    return get_home_url() . '/' . $folder . $qstring;
}

function get_the__uri_that_switches_views() {
    global $format;
    $args = array();
    if (array_key_exists('order', $_GET))  {
        $args['order'] = $_GET['order'];
    }
    if (array_key_exists('paged', $_GET))  {<commit_msg>FIX productions: affichage en liste/pastilles ne gardent pas la page où on est<commit_after><?php
/**
 * The template for displaying Archive pages.
 *
 * Used to display archive-type pages if nothing more specific matches a query.
 * For example, puts together date-based pages if no date.php file exists.
 *
 * If you'd like to further customize these archive views, you may create a
 * new template file for each specific one. For example, Twenty Twelve already
 * has tag.php for Tag archives, category.php for Category archives, and
 * author.php for Author archives.
 *
 * Learn more: http://codex.wordpress.org/Template_Hierarchy
 *
 */

get_header(); ?>

<?php
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;

/* HOW TO SORT */

// These are the default options
// correspond to url /production/

$args = array(  'posts_per_page' => 12, 
                'paged' => $page,
                'post_type' => 'production',
                'orderby' => 'meta_value',
                'meta_key' => '<KEY>',
                'order' => 'DESC');

/*  We allow to specify a different order through the url, i.e.
 *
 *  /production/?order=ASC
 */

if (array_key_exists('order', $_GET))  {
    $args['order'] = $_GET['order'];
}

/*  We also allow to specify a different column to order by,
 *  and in case of ordering by a meta value, which one:
 * 
 *  /production/?orderby=title
 *  /production/?orderby=title&order=ASC
 *  /production/?orderby=meta_value&meta_key=wpcf-genre&order=ASC
 *
 */
 
if ( array_key_exists('orderby', $_GET) )  {
    $args['orderby'] = $_GET['orderby'];
    if ( $_GET['orderby'] == 'meta_value' && array_key_exists('meta_key', $_GET))  {
        $args['meta_key'] = $_GET['meta_key'];
    }
}

if ($args['orderby'] != 'meta_value') {
    unset( $args['meta_key'] );
}

query_posts($args);


/* HOW TO DISPLAY */

$format = 'detail';

if ( array_key_exists('format', $_GET) )  {
    $format = $_GET['format'];
}
function get_the_production_uri($args=array()) {
    global $format;
    global $page;
    $folder = '';
    
    if ( !get_option( "permalink_structure" ) ) {
        // uri starts with /?post_type=production&page=n&
        $args = array('post_type' => 'production') + $args;
        if ($page > 1) {
            $args = array('paged' => $page) + $args;
        }
    } else {
        // uri starts with /production/page/n/
        $folder = 'production/';
        if ($page > 1) {
            $folder .= 'page/' . $page . '/';
        }
        
        
    }
    if (!array_key_exists('format', $args))  {
        $args['format'] = $format;
    }
    $qstring = http_build_query($args);
    if ($qstring) {
        $qstring = '?' . $qstring;
    }

    return get_home_url() . '/' . $folder . $qstring;
}

function get_the__uri_that_switches_views() {
    global $format;
    $args = array();
    if (array_key_exists('order', $_GET))  {
        $args['order'] = $_GET['order'];
    }
    if (array_key_exists('paged', $_GET))  {
{'fraction_non_alphanumeric': 0.1634682484298674, 'fraction_numerical': 0.0013956734124214933, 'mean_word_length': 2.8528225806451615, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 24, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1034301', 'n_tokens_mistral': 1936, 'n_tokens_neox': 1883, 'n_words': 481}