Sadece belirli kategoriler vurgulayarak wordpress üzerinde birden fazla takvim

1 Cevap php

Herkes her biri sadece belirli bir kategori içinde olan günleri vurgulayarak nasıl, wordpress, ben bir sitede birçok takvimler uygulamak, biliyor mu? Ben kendi kedi tüm olayları izleme kurulumu birden fazla takvim, her umuyorum.

Bir süre araştırma yaptıktan sonra, ben bulabildiğim en iyi bu konu oldu:

http://wordpress.org/support/topic/266627?replies=11

Bir çalışma çözeltisi hiç yoktur Ama önce peter dışarı görünüyor

1 Cevap

Ne aşağıda olması belli bir kategoriden mesajlar gün (günlük arşiv sayfasına) cari ay ve bağlantıları gün tükürür. Sadece görüntülemek istediğiniz her kedi için kod çoğaltmak. Kullanılabilir olması için, bunu güzel bir takvim satırları vermek ve muhtemelen kısmi / birden fazla ay kapsayacak şekilde komut genişletmek için bazı koşullu biçimlendirme eklemek gerekir, ancak bu başlangıç ​​almalısınız.

<?php 

$today = getdate();
query_posts( 'category_name=mycat' . '&year=' . $today["year"] . '&monthnum=' . $today["mon"] );  // query_posts() is a WP function

if ( have_posts() )
{
    $postDates = array();
    while ( have_posts() )
    {
        // The if/while we're in now is called the "WordPress Loop"

        the_post();  // Sets all the WP variables up for the current post
        $postDates[] = (int)(the_date("j", "", "", FALSE));  // the_date() is a WP function
    }

    for ( $i = 1; checkdate ( (int)(date("n")), $i, (int)(date("Y")) ); $i++ )
    {
        // checkdate() is a PHP function which validates a date against the gregorian calendar
        if ( in_array($i, $postDates) )
        {
            echo "<a href=\"" . get_day_link('','',$i) . "\">" . $i . "</a> ";  // get_day_link() is a WP archive function 
        }
        else
        {
            echo $i . " ";
        }
    }
}

wp_reset_query();  // Resets the WP variables so everything's back to normal

?>

HTML output:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 <a href="http://www.myblog.com/2010/04/17/">17</a> 18 19 20 21 22 23 24 25 26 27 28 29 30