Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter matthieu14

    (@matthieu14)

    Hello all, it is solved also for me ?? !

    Thread Starter matthieu14

    (@matthieu14)

    Thanks a lot Menaka, it is solved !

    Thread Starter matthieu14

    (@matthieu14)

    Hello Menaka,

    Sorry for responding late, I was off for a few days.

    Here are my comments :

    add_action(‘pre_get_posts’,’alter_query’);
    function alter_query($query) {
    // if the pages do not belong to the category “niveau-1”, “niveau-2” up to “niveau-6”, do nothing
    if (is_category(‘niveau-1’)==false and is_category(‘niveau-2’)==false and is_category(‘niveau-3’)==false and is_category(‘niveau-4’)==false and is_category(‘niveau-5’)==false and is_category(‘niveau-6’)==false)
    return;
    // if the page belongs to one of the aforementionned categories do the following
    // modify the query by ordering the posts by a meta_key called “ordon” that I have created for the posts belonging to the aforementionned categories.
    // and order by an ascending order
    $query-> set(‘orderby’ ,’meta_value_num’);
    $query-> set(‘meta_key’,’ordon’);
    $query-> set(‘order’,’ASC’);
    }

    It is likely that this query is causing the problem since the menu is not displayed only for the categories concerned by the if condition..

    Is it clearer ?
    Thanks in advance,

    M.

    Thread Starter matthieu14

    (@matthieu14)

    Hello Menaka,

    1. Yes I have altered the query for this kind of pages using the following snippet:

    add_action('pre_get_posts','alter_query');
    function alter_query($query) {
    	//gets the global query var object
    	if (is_category('niveau-1')==false and is_category('niveau-2')==false and is_category('niveau-3')==false and is_category('niveau-4')==false and is_category('niveau-5')==false and is_category('niveau-6')==false)
    		return;
    
    	$query-> set('orderby' ,'meta_value_num');
        $query-> set('meta_key','ordon');
        $query-> set('order','ASC');
    }

    The idea is to order the posts of these subcategories by a meta-key called “ordon”. Is it possible that it makes the menu disappear?

    2. I tried to disable all of them, it does not change anything

    Thread Starter matthieu14

    (@matthieu14)

    Hello Menaka S,

    Thanks for your answer.

    You are right, the menu is displayed in some categories like the one you have quoted ! But I have no customized category page.

    Yet, I think we have a clearer picture of the problem now : the menu is not displayed only on “sub-category” pages. Indeed, on categories like Cours de turc or Themes, the menu is displayed but in categories included into other categories such as Niveau 1 which belongs to Cours de turc, the menu is not displayed.

    How can we fix that ?

    Thank you in advance !

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