authorの記事一覧でpostとカスタム投稿タイプの両方を表示するには?
-
テーマはSandboxを使用しています。
投稿と固定ページに加えて、checkという名前のカスタム投稿タイプを使っているので、
記事の末尾にある This entry is written by username というところを
クリックしたときに、username の post だけでなく check も表示したいと思っているのですが、
実現できません。http://ja.forums.wordpress.org/topic/6080を参考にして、function.php の末尾に
add_filter( 'getarchives_where', 'my_getarchives_where', 10, 2 ); function my_getarchives_where( $where, $r ) { global $my_archives_post_type; if ( isset($r['post_type']) ) { $my_archives_post_type = $r['post_type']; $where = str_replace( '\'post\'', '\'' . $r['post_type'] . '\'', $where ); } else { $my_archives_post_type = ''; $where = str_replace( 'post_type = \'post\'', 'post_type in (\'post\', \'check\')', $where ); } return $where; } add_filter( 'get_archives_link', 'my_get_archives_link' ); function my_get_archives_link( $link_html ) { global $my_archives_post_type; if ( '' != $my_archives_post_type ) $add_link .= '?post_type=' . $my_archives_post_type; $link_html = preg_replace("/href=\'(.+)\'\s/","href='$1".$add_link."'",$link_html); return $link_html;
というコードを追加してみましたが、まだこれでもだめなようです。
どうするのがよいでしょうか?
2件の返信を表示中 - 1 - 2件目 (全2件中)
2件の返信を表示中 - 1 - 2件目 (全2件中)
- トピック「authorの記事一覧でpostとカスタム投稿タイプの両方を表示するには?」には新たに返信することはできません。