wp_list_categories & Empty Categories

dev.xiligroup is being renovated Forums xili-language plugin wp_list_categories & Empty Categories

Tagged: , ,

This topic contains 0 replies, has 4 voices, and was last updated by  Anonymous 7 years, 7 months ago.

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #2984

    Anonymous

    I believe if you add a language tag to the arg variable (like in the page of posts template http://codex.wordpress.org/Pages )

    $args = array(
    'cat' => $catid,
    'paged' => $paged,
    'order' => $order,
    'ignore_sticky_posts' => $do_not_show_stickies,
    'lang' => the_curlang()
    );

    You should be able to make it come up with a blank category if there is nothing there for the language…not sure though.

    So the tag ‘lang’ => the_curlang() is what you want (where cur Lang is the current language).

    Hope that helps,

    Nathan

    #2985

    Anonymous

    Thank you for your answer sungkhum.

    Unfortunately it is not working. the_curlang() works fine obviously but I don’t think it is possible to use such ‘lang’ argument within wp_list_categories.

    Am I wrong ?

    #2986

    Anonymous

    I didn’t test it, but are you sure you can’t? Look here http://codex.wordpress.org/Template_Tags/wp_list_categories

    You should be able to pass the language variable…

    Not positive though.

    -Nathan

    #2987

    Anonymous

    Your case is not very current.

    wp_list_categories is a transverse list (taxonomy) in multilingual context because as you observe (or see inside source) continue to create link (and title) adapted to the current language ( and when clicked, fires a query to select posts in a language AND in a category)… wp_list_pages works on pages but not on taxonomies like wp_list_categories..

    I will try if it possible to find a hook to adapt the count of each category when language sub-select is active… no garanties … just the time to dive in wp code ;-)

    Be patient

    #2988

    Anonymous

    @sungkhum

    I tried your solution and it doesn’t seem to work. In my opinion it is logical because if I click on Cat1, there is no post (because I am on the French side). So the language parameter is already taken into account, but yet, Cat1 is displayed on the list.

    @Michel

    I agree that my case is not a common one :)

    And now I am asking myself if I am seeing things the wrong way… Another solution woull be to print out posts with default language when the translation is not available. It will solve my first problem and improve the website but I don’t really know how to do it. I have to look at the query…

    So, no solution for the time being but I thank you both for your messages :-)

    #2989

    xiligroup dev
    Keymaster

    remember that counter in taxonomies is updated when a post (or custom post) is attached to a term (a category) of the taxonomy. When buiding wp_categories_list, a « walker » check – according settings and count – if a line must displayed or not…

    In multilingual context on a standalone db as in current wp install, this count is a little faulty if targeted for one language. The question is : must we create a special api for very rare situation to maintain a counter for each language.

    Another approach for professional commercial high level website is to use xili-language premium on a wp network install as described here… but it is yet not free… https://dev.xiligroup.com/?p=1961

    dev.xiligroup author

    #2990

    Anonymous

    Thanks for this explanation. I am not sure xili-language premium will provide better features for me, since I believe I can use the fact that both languages are in the same db.

    Maybe the best idea in my case is to show the available post with default language when no translation is available. This I don’t know how to do it yet, but I am currently looking into it.

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

You must be logged in to reply to this topic.