I
I
Igor Pushkarsky2015-11-09 08:46:46
WordPress
Igor Pushkarsky, 2015-11-09 08:46:46

Why did WP stop working removing articles from a category?

I was making a website template, everything was moving towards completion, when I realized that the cycle stopped working, news output and the like.
Rather, the number of records is displayed normally, as much as in the database, but the pieces of the type <?php the_title();?>give an empty value.
Previously, everything worked with a bang.
I suspect that only these plugins are the problem. Maybe there is another way to display articles?

<?php if ( have_posts() ) : ?>

                    <?php
                    // Start the loop.
                    while ( have_posts() ) : the_post();?>

                      <!--  get_template_part( 'category-news-item', get_post_format() );-->


                        <article class="news-item" itemscope="" itemtype="http://schema.org/NewsArticle" >
                            <meta itemprop="datePublished" content="<?php the_time( 'j F Y' ); ?>">
                            <meta itemprop="author" content="<?php the_author(); ?>">
                            <meta itemprop="inLanguage" content="ru-RU">
                            <div class="news-data"><?php the_time( 'j F Y' ); ?></div>
                            <h3 class="news-title" itemprop="headline"><?php the_title();?></h3>
                            <div class="news-image">
                                <?php echo get_the_post_thumbnail($page->ID); ?>
                            </div>
                            <div class="news-text" itemprop="description" >
                                <p><?php the_excerpt(); ?></p>
                                <a href="<?php echo get_permalink(); ?>" class="news-link" itemprop="url" >Подробнее..</a>
                            </div>
                            <div class="clearfix"></div>
                            <hr/>
                        </article>

                    <?endwhile;

                else :
                    get_template_part( 'content', 'none' );

                endif;
                ?>

Also, for some unknown reason, I began to randomize the contents of articles in the same cycle.
For example, I go to site.com/verse-1/ shows the content of this verse, and the title of any other from the same category, and if you refresh the page, then the link remains the same, but the content changes.
<?php
/*
Template Name Posts: Страница стихотворения
*/
?>

<?php get_header() ?>

<article <?php post_class(); ?>>

    <div class="content-book-container" itemscope itemtype="http://schema.org/Article">
        <meta itemprop="inLanguage" content="ru-RU">
        <meta itemprop="author" content="Евгений Узденский">
        <meta itemprop="datePublished" content="2015-01-17">
        <meta itemprop="interactionCount" content="Просмотров: 15">
        <meta itemprop="articleSection" content="Глум">
        <meta itemprop="articleSection" content="Поржать">

        <div class="edge-book-up">
            <div class="left"></div>
            <div class="center"></div>
            <div class="right"></div>
        </div>

        <div class="poem-box immanentnii-besceller zerkala">

            <div class="nav-arrow-box">
                <?php next_post_link('%link', ' <span class="nav-arrow -top-next" rel="next"><i class="right-arrow"></i></span>', TRUE); ?>
                <?php previous_post_link('%link', '<span class="nav-arrow -top-prev" rel="prev"><i class="left-arrow"></i></span>', TRUE); ?>
                <hr>
                <?php next_post_link('%link', '<span class="nav-arrow -bottom-next" rel="next"><i class="right-arrow"></i></span>', TRUE); ?>
                <?php previous_post_link('%link', '<span class="nav-arrow -bottom-prev" rel="prev"><i class="left-arrow"></i></span>', TRUE); ?>
            </div>

            <div class="poem-image">
                <img itemprop="image" src="<?php echo get_field('poem-image') ?>"
                     alt="<?php echo  the_title()?>"/>
            </div>


            <div class="poem-text">
                <div class="orange-opacity-top"></div>
                <div class="orange-gradient-top"></div>

                <div class="orange-content">
                    <div class="icon-box-auxiliary">
                        <a href="#" title="Слушать" class="auxiliary-icon-volume "></a>
                        <a href="#" title="Печать" class="auxiliary-icon-print  "></a>
                        <a id="open-close-poem" href="#" title="Развернуть" class="auxiliary-icon-close  "></a>
                    </div>
                    <audio class="audio-player" controls>
                        <source src="<?php echo get_field('audio') ?>" type="audio/mpeg">
                        Тег audio не поддерживается вашим браузером.
                        <a href="<?php echo get_field('audio') ?>">Скачайте музыку</a>.
                    </audio>

                    <h1 itemprop="headline"><?php echo  the_title()?></h1>

                    <div itemprop="articleBody" class="poem-body">
                        <div class="inner">

                            <?php while ( have_posts() ) : the_post(); ?>
                                <?php the_content();?>
                            <?php endwhile; ?>
                        </div>
                    </div>
                </div>

                <div class="orange-gradient-bottom"></div>
                <div class="orange-opacity-bottom"></div>

            </div>
        </div>

        <div class="edge-book-bottom">
            <div class="left"></div>
            <div class="center"></div>
            <div class="right"></div>
        </div>
    </div>


</article>

<?php get_footer() ?>

Maybe it's because of the main page randomit?
<?php
// устанавливаем параметры для get_posts()
$args = array(
    'numberposts' => 1,
    'category' => '9',
    'orderby' => 'rand'
);

// берем случайный пост из базы данных
$randomPost = get_posts ( $args );

foreach ( $randomPost as $post ) {

    //var_dump(get_permalink ( $post->ID ));
    // redirect the user to the random post
    wp_redirect ( get_permalink ( $post->ID ) );
    exit;
}

?>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Igor Pushkarsky, 2015-11-09
@RainMEN

Doesn't anyone know? It works in standard themes. The question is why?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question