2017-05-10 3 views
0

私はISSUE_NUMBERというカスタムポストタイプを持っていると私はここで、この画像のようにアーカイブページを作成したい:年のサムネイルwp_get_archivesに

私は今年

 <?php 
     $my_archives=wp_get_archives(array(

      'post_type'=>'issue_number', 
      'type'=>'yearly', 
      'format' => 'custom', 


    'before' => ' 
    <h3 class="entry-title mh-loop-title archivio-anno-list">Table of 
     contents<br> 
    ', 

    'after' => ' 
    <br> 
    <p>hello</p> 

    <img src="<?php the_post_thumbnail_url(); ?>" alt="Mountain View" 
    style="width:33%;float:left;"> 
    <img src="" alt="Mountain View" style="width:33%;float:left;"> 
    <img src="" alt="Mountain View" style="width:33%;float:left;"> 
    <img src="" alt="Mountain View" style="width:33%;float:left;"> 
    <img src="" alt="Mountain View" style="width:33%;float:left;"> 
    <img src="" alt="Mountain View" style="width:33%;float:left;"> 


    <br></h3>', 



'show_post_count'=>true, 
'limit'=>20, 



    )); 

     print_r($my_archives); 



      ?> 
の自動サムネイルをしたいです

この作品はサムネイルではありません...

+0

これは本当に混乱するコードです...その '<?php the_post_thumbnail_url(); ?> 'はまったく動作しません。 [** 'wp_get_archives()' **](https://codex.wordpress.org/Function_Reference/wp_get_archives)は、単純なパラメータを期待しており、そこに重いHTMLを与えています。解決策が何であるかはっきりしないが、wp_get_archivesだけでは仕事をしないと思う – brasofilo

答えて

0

解決済み

問題を解決しました。問題は、ANNOという新しいカスタム投稿タイプとyear to issue_numberのanno_issueという1つの関係フィールドを追加して解決しました。このコードはクエリのためのものです:

<?php 

// args 
    $args = array(
‘numberposts’ => -1, 
‘post_type’ => ‘anno’, 
    ‘posts_per_page’ => 100, 
    ); 

// query 
    $the_query = new WP_Query($args); 

    ?> 

      <?php while($the_query->have_posts()) : $the_query- 
     >the_post(); 
    mh_before_page_content(); 
    mh_magazine_page_title();?> 

    <?php 

    /* 
    * Query posts for a relationship value. 
     * This method uses the meta_query LIKE to match the string “123” 
to the database value a:1:{i:0;s:3:”123″;} (serialized array) 
*/ 

$posts = get_posts(array(
    ‘post_type’ => ‘issue_number’, //nome post type da dove recupero le 
    info 
    ‘posts_per_page’ => -1, 
    ‘meta_query’ => array(
    array(
    ‘key’ => ‘anno_issue’, // nome custom field all’interno di post che mi 
    da 
l’info 
‘value’ => ‘”‘ . get_the_ID() . ‘”‘, // matches exaclty “123”, not just 
123. This prevents a match for “1234” 
     ‘compare’ => ‘LIKE’ 
    ) 
    ) 
    )); 

    ?> 
    <?php /*ciclo stampa articoli */ ?> 
    <?php if($posts): ?> 

    <?php foreach($posts as $post): ?> 
    <?php /*layout 1 del tema per articoli */ ?> 
<article > 

    —HTML CODE DISPLAYNG YOUR LOOP— 
</article> 
    <?php /*fine layout 1 */ ?> 
    <?php endforeach; ?> 

    <?php endif; ?> 

    <?php /*fine ciclo stampa articoli */ ?> 

    <?php endwhile; // end of the loop. ?>