• Resolved tsakano

    (@tsakano)


    大変使いやすく、いくつものサイトに利用させていただいております
    そこで、クライアントから来年度は表示しないようにオーダーがあり困っています
    例えば今年度だけ(2022年3月まで)を表示するようなことは出来るのでしょうか

    よろしくお願いいたします

    The page I need help with: [log in to see the link]

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author ishitaka

    (@ishitaka)

    こんにちは

    下記のようなコードでカレンダーの表示を2022年3月までに制限することができます。

    子テーマの functions.php に、

    function my_xo_event_calendar_args( $args ) {
        // if ( 'xo_event_calendar-1-calendar' !== $args['id'] ) return $args;
    
        $y = 2022;
        $m = 3;
    
        $date1 = strtotime( date_i18n( 'Y-m-01' ) );
        $date2 = strtotime( "{$y}-{$m}-01" );
        $month1 = date( 'Y', $date1 ) * 12 + date( 'm', $date1 );
        $month2 = date( 'Y', $date2 ) * 12 + date( 'm', $date2 );
        $diff = $month2 - $month1;
        if ( $diff < 0 ) {
            $args['year'] = $y;
            $args['month'] = $m;
            $args['next_month_feed'] = -1000;
        } else {
            $args['next_month_feed'] = $diff;
        }
    
        return $args;
    }
    add_filter( 'xo_event_calendar_args', 'my_xo_event_calendar_args' );

    参考ページ:
    xo_event_calendar_args フィルターフック
    https://xakuro.com/wordpress/xo-event-calendar/xo-event-calendar-args/

    Thread Starter tsakano

    (@tsakano)

    ありがとうございます

    $date1 = strtotime( date_i18n( 'Y-m-01' ) );
    この行がエラー表示
    syntax error, unexpected ‘&’
    となってしまいます

    Plugin Author ishitaka

    (@ishitaka)

    提示のコードのままであれば、そのようなエラーにはならないと思います。一度そのままのコード(コピペ)で試してみてください。

    Thread Starter tsakano

    (@tsakano)

    ありがとうございます

    お陰様で実装できました
    これからも使わせていただきます

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘年度表示について’ is closed to new replies.