サポート » プラグイン » display postの日付の順序変更について

  • 解決済 osat99

    (@osat99)


    display postプラグインで、日付はタイトルの次に表示される仕様になってますが、これをタイトルの前、先頭へ持っていくには、どのファイルの改変を行えばいいでしょうか?
    現状、CSSで先頭へは持っていっておりますが、根本的に変えたいもので。

    この手のプラグイン「List category posts」もそうなのですが、日付がタイトルの次になってますね。
    これが世界標準なのでしょうか。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • kimipooh

    (@kimipooh)

    プラグイン自体を変更しても、プラグインが更新されたら、もとに戻ります。
    https://ja.wordpress.org/plugins/display-posts-shortcode/
    のプラグインであれば、自由にカスタマイズできるフック「display_posts_shortcode_output」が用意されているので、これを使えばよいでしょう。

    利用方法は、
    1. FTP接続等サーバーに接続して、テーマの functions.php にアクセスできるようにする
    2. テーマの functions.php をバックアップしておく
    3. テーマの functions.php の末尾に次のコードを追加する

    add_filter( 'display_posts_shortcode_output' , 'display_posts_shortcode_output' , 10 , 11 );
    
    function display_posts_shortcode_output($output, $original_atts, $image, $title, $date, $excerpt, $inner_wrapper, $content, $class, $author, $category_display_text){
    
    	$output = '<' . $inner_wrapper . ' class="' . implode( ' ', $class ) . '">' . $image . $date . " " . $title  . $author . $category_display_text . $excerpt . $content . '</' . $inner_wrapper . '>';
    
    	return $output;
    }

    日付は (日/月/年) 表記になりますが、そこは
    date_format=”Y/m/d”
    のショートカットプションによって、順序を変更(初期値は、 (d/m/Y) の模様)しておけばよいと思います。
    また$output 内をいじると、自由にカスタマイズできるでしょう。

    • この返信は3年前にkimipoohが編集しました。
    トピック投稿者 osat99

    (@osat99)

    kimipooh 様

    ありがとうございます。
    うまく順序入れ替わりました。

2件の返信を表示中 - 1 - 2件目 (全2件中)
  • トピック「display postの日付の順序変更について」には新たに返信することはできません。