0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

WordPressプラグインYARPPのrelated_posts()のテンプレート指定方法

Posted at

前提

YARPP 4.2.4で動作確認

  • mythemeをテーマとして使っている
  • テーマディレクトリ直下にテンプレのファイルが置いてある
  • 例: /path/to/wordpress/wp-content/themes/mytheme/yarpp-template-myapp.php

コード

related_posts(array('template' => 'yarpp-template-myapp.php'));

YARPPの3系とかは下の指定方法だった模様。ググってヒットするものが下のような例ばかりで動かず、結局コードみた。

related_posts(array('template_file' => 'yarpp-template-myapp.php'));
related_posts(array('use_template' => true, 'template_file' => 'yarpp-template-myapp.php'));

参考

古いoptionを新しい仕様に更新している箇所

# wp-content/plugins/yet-another-related-posts-plugin/includes/yarpp_options.php

125     $new_options['template'] = $_POST['use_template'] == 'custom' ? $_POST['template_file'] :
126         ( $_POST['use_template'] == 'thumbnails' ? 'thumbnails' : false );
127     $new_options['rss_template'] = $_POST['rss_use_template'] == 'custom' ? $_POST['rss_template_file'] :
128         ( $_POST['rss_use_template'] == 'thumbnails' ? 'thumbnails' : false );
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?