• umsybe

    (@umsybe)


    Hello!


    For some reason, you think that if there are no posts in a category, then it is not needed on the site and is of no interest to users.
    This is completely wrong!


    For a category without entries, you can make a description and this will be a full-fledged page for people and search engines in the general menu of categories.

    I did not find an option on how to include the correct URLs in the switcher for a category without entries in the file \vendor\wpsyntex\polylang\include\switcher.php ,
    so I had to edit the code in /vendor\wpsyntex\polylang\frontend\frontend-links.php
    so that it does not check for the presence of entries in the category.

    public function get_translation_url( $language ) {

    // Check if translated term ( or children ) have posts
    $count=1; // $count = $tr_term->count || ( is_taxonomy_hierarchical( $term->taxonomy ) && array_sum( wp_list_pluck( get_terms( $term->taxonomy, array( 'child_of' => $tr_term->term_id, 'lang' => $language->slug ) ), 'count' ) ) );

    I added $count=1; // at the beginning of the line.

    Please make this option in the plugin so that you don’t have to edit the code!

    • This topic was modified 10 months ago by umsybe.
  • The topic ‘Make an option so categories without posts in the switcher have a normal URL’ is closed to new replies.