WordPress>

1 Cevap php

Benim özel WP tema için yeni bir mesaj komut kod denedim, ancak yeni bir mesaj ile WP gemi parçacığını beri, ideal ben sadece geçen, benim sidebar.php komut dosyası içinde olduğunu aramak gerekir bana oluşur Bu parametreyi "mesajların sayısı göstermek için".

Herkes bunu nasıl biliyor?

1 Cevap

WordPress sunan sorgu API kullanın: http://codex.wordpress.org/Function_Reference/WP_Query

Örnek:

<?php
    $myQuery = new WP_Query(
        array(
            'nopaging'    => true,
            'post_type'   => 'post',
            'post_status' => 'publish',
            'post_count'  => 5
        )
    );

    if ( $myQuery->have_posts() )
    {
        while ( $myQuery->have_posts() )
        {
            $post = $myQuery->next_post();
            ?>
    Do whatever you want …
    To test for the current page:
    <a href="<?php the_permalink(); ?>"
    <?php
    if ( $_SERVER['REQUEST_URI'] == str_replace(
            'http'
                . ( empty ( $_SERVER['HTTPS'] ) ? '' : 's' )
                . '://' . $_SERVER['HTTP_HOST'], '',
            get_permalink()
        ) )
    {
        print ' class="current"';
    }
    ?>
    ><?php the_title(); ?></a>
            <?php
        }
    }
?>