Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter Medesko

    (@medesko)

    Hi ,
    Thanks for your explain.

    I followed your explanation and work perfectly! here is my code !

    Thank for code quality checking!
    `
    function custom_get_xxx_post_where($whereSql) {
    global $custom_get_xxx_post_where;
    if(isset($custom_get_xxx_post_where) === true AND $custom_get_xxx_post_where === true) {
    if($_SESSION[‘cat_name’] == ‘dsi’) {
    $whereSql .= ‘ AND tt.term_id = 2 ‘;
    } else if($_SESSION[‘cat_name’] == ‘metiers’) {
    $whereSql .= ‘ AND tt.term_id = 3 ‘;
    }
    }
    return $whereSql;
    };
    add_filter(‘get_previous_post_where’, ‘custom_get_xxx_post_where’);
    add_filter(‘get_next_post_where’, ‘custom_get_xxx_post_where’);

    <?php
    $custom_get_xxx_post_where = true;
    previous_post_link(‘<div class=”dossier-control hidden-sm hidden-xs”> %link</div>’, ‘Prev’, true);
    next_post_link(‘<div class=”dossier-control hidden-sm hidden-xs”>%link</div>’, ‘Next’, true);
    $custom_get_xxx_post_where = false;
    ?>
    `

    Thread Starter Medesko

    (@medesko)

    Thank you it works well now

    Thread Starter Medesko

    (@medesko)

    [Code moderated as per the Forum Rules. The maximum number of lines of code that you can post in these forums is ten lines. Please use the pastebin]

    Thread Starter Medesko

    (@medesko)

    Hello It work now in Archives.php
    I juste change your condition Thank u so much
    the code is

    <?php // Check category and parent category for matching sidebar
    $cat_id          = get_query_var('cat'); // Get ID of current category
    $cat_term        = get_term_by( 'id', $cat_id, 'category' ); // Use ID to get category data
    $cat_slug        = $cat_term->slug; // Get category slug from data
    $cat_parent_id   = $cat_term->parent; // Get parent category ID from data
    $cat_parent_term = get_term_by( 'id', $cat_parent_id, 'category' ); // Use ID to get parent category data
    $cat_parent_slug = $cat_parent_term->slug;
    
     // Get parent category slug from data
    
    	if(!theme_dynamic_sidebar( $cat_slug ) AND !theme_dynamic_sidebar( $cat_parent_slug )) {
    		theme_dynamic_sidebar('right');
    	} // Load sidebar file that matches category parent slug
    	//theme_dynamic_sidebar('right'); // Load default sidebar file
    ?>
    Thread Starter Medesko

    (@medesko)

    My default category genere by archive.php is
    commerce, sorties, habitat, loisirs

    I created in my thèmes sidebar-commerce.php , sidebar-sorties.php
    sidebar-habitat.php sidebar-losirs.php

    I insert the conditional in artchive.php
    on its ligne for condition I add my default
    get_sidebar(‘right’); // Load default sidebar file

    Now how to make it work with categories that are not slug ?

    Thread Starter Medesko

    (@medesko)

    Is that it is possible to do by default category Archive.php
    I have a category that are not slug.

    thank you for your understanding

    Thread Starter Medesko

    (@medesko)

    thank you so much for your answers

Viewing 7 replies - 1 through 7 (of 7 total)