WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [Plugin: Smart Archives Reloaded] Excluding not working (12 posts)

  1. chavo
    Member
    Posted 4 years ago #

    Hi. I having troubles excluding categories. It doesn't work. If is possible to be a bug?

  2. scribu
    Member
    Posted 4 years ago #

    What version of the plugin are you using?

    What are you using to exclude cateogories? The settings page, shortcode, template tag?

    Please paste the relevant code.

  3. chavo
    Member
    Posted 4 years ago #

    Hi Scribu. I'm using version 1.8.3. I'm using the template tag <?php smart_archives(); ?>

    And the settins page is like this:

    Exclude Categories by ID: 1,2,3,4,5,6,7,8

    Format: block

    Use wp-cron: unckecked.

  4. scribu
    Member
    Posted 4 years ago #

    Try the "Clear cache" button in Settings -> Smart Archives.

    Also try the development version.

  5. chavo
    Member
    Posted 4 years ago #

    Hi Scribu. Development version works fine now. I just want to know if is possible to exclude child categories. I have a parent category named as "News / Blog". This category has 2 child categories: "eng" (for english posts) and "esp" for spanish posts. When you are at "news-blog" category, I use conditional tags and language sessions. So, if session = esp, I use a query_post call to show only posts belonging to "esp" child category. And if session = eng, show only posts from "eng" child categories. I tried to duplicate the plugin, but if doesn't works.

  6. chavo
    Member
    Posted 4 years ago #

    Hi Scribu. It's me again. Well...I just code a little bit the output format of months links editing generator.php

    Take a look at this:

    if ($_SESSION["idioma"]=="esp") {
    if ( $posts = $wpdb->get_results($query) ) {
    $month = array(
    'posts' => $posts,
    'link' => get_month_link($year, $i) .'?category_name=esp'
    );
    self::$monthsWithPosts[$year][$i] = $month;
    }
    } else {
    if ( $posts = $wpdb->get_results($query) ) {
    $month = array(
    'posts' => $posts,
    'link' => get_month_link($year, $i) .'?category_name=eng'
    );
    self::$monthsWithPosts[$year][$i] = $month;
    }
    }

    Now I'm wondering how to change the timestamp format. I mean...I want that if session = esp, month abbreviation be in spanish (ENE, FEB, MAR, etc.) but if session = eng display JAN, FEB, MAR, etc.

    Thanks in advance and sorry for my bad english.

  7. chavo
    Member
    Posted 4 years ago #

    I guess that I have to apply some filter, but don't know how.

  8. scribu
    Member
    Posted 4 years ago #

    See this guide.

  9. chavo
    Member
    Posted 4 years ago #

    Hi Scribu. Thanks for your always generous reply. I see the guide but I can't catch how to apply a filter or customize the wp_locale output.

    I found the lines in generator.php where is supposed to code the wp_locale output and I was a long time roundarounding it...but I couldn't get it working.

    I'm do this:

    if ( 'short' == $format )
    if ($_SESSION["idioma"]=="esp") {
    $month = $wp_locale->get_month_abbrev($month);
    } else {
    /* here is supposed to be the english month abbreviation stuff */
    ...
    }
    $months[$i] = esc_html($month);

    Do you know what I have to do to apply and english month format?

    Thanks!

  10. chavo
    Member
    Posted 4 years ago #

    Well Scribu. I hardcoded the locale.php file at wp-includes folder to get the plugin workings as I wanted. I duplicated de get_month_abbrev function as it follows:

    First, I duplicated month_abbrev:

    $this->month_abbrev_eng[__('January')] = __('Jan');
    $this->month_abbrev_eng[__('February')] = __('Feb');
    $this->month_abbrev_eng[__('March')] = __('Mar');
    $this->month_abbrev_eng[__('April')] = __('Apr');
    $this->month_abbrev_eng[__('May')] = __('May');
    $this->month_abbrev_eng[__('June')] = __('Jun');
    $this->month_abbrev_eng[__('July')] = __('Jul');
    $this->month_abbrev_eng[__('August')] = __('Aug');
    $this->month_abbrev_eng[__('September')] = __('Sep');
    $this->month_abbrev_eng[__('October')] = __('Oct');
    $this->month_abbrev_eng[__('November')] = __('Nov');
    $this->month_abbrev_eng[__('December')] = __('Dec');
    
    foreach ($this->month_abbrev_eng as $month_ => $month_abbrev_eng_) {
    $this->month_abbrev_eng[$month_] = preg_replace('/_.+_abbreviation$/', '', $month_abbrev_eng_);}

    Then, I declared the function:

    function get_month_abbrev_eng($month_name) {
    return $this->month_abbrev_eng[$month_name];}

    And finally, apply conditional tags to generator.php file from your plugin:

    if ($_SESSION["idioma"]=="esp") {
    // HERE I CALL NORMAL TRANSLATION FROM WP->LOCAL IN LOCALE.PHP
    $month = $wp_locale->get_month_abbrev($month);
    } else {
    // HERE I CALL SPECIAL HARDCODED TRANSLATION IN LOCALE.PHP
    $month = $wp_locale->get_month_abbrev_eng($month);
    }

    That's all! Thanks for your plugin.

  11. chavo
    Member
    Posted 4 years ago #

    Where I put:

    $this->month_abbrev_eng[__('May')] = __('May');

    I must have to put:

    $this->month_abbrev_eng[__('May')] = __('May_May_abbreviation');

  12. scribu
    Member
    Posted 4 years ago #

    I really don't have time to look into it at the moment.

    Perhaps you can ask on WP Questions for a solution that doesn't involve modifying core files.

Topic Closed

This topic has been closed to new replies.

About this Topic