Попытка добавить нумерацию страниц в пользовательский массив в шаблоне WordPress - PullRequest
0 голосов
/ 12 октября 2019

Я унаследовал сайт WordPress, который использует шаблоны тем для поиска сообщений. Я действительно хотел бы добавить нумерацию страниц к этим шаблонам, но когда я следую другим инструкциям о том, как это сделать, это дает «у сайта технические проблемы: ошибка.

Я пробовал много разных решений (см. Ошибку выше)

Массив

<?php



$args = array(
    'numberposts'   => 9999,
    'post_type'     => 'post',
    'cat'           => 2,       
    'meta_query'    => array(
    'relation'      => 'AND',
                array(
                'relation'      => 'AND',
                                        array(
                                        'relation'      => 'AND',
                                                    array(
                                                    'key'       => 'Price',
                                                    'type'      => 'NUMERIC',
                                                    'value'     => $maxprice,
                                                    'compare'   => '<'
                                                    ),
                                                    array(
                                                    'key'       => 'Price',
                                                    'type'      => 'NUMERIC',
                                                    'value'     => 999000000,
                                                    'compare'   => '<'
                                                    )                                                           
)
),
                array(
                'relation'      => 'AND',
                                        array(
                                        'relation'      => 'AND',
                                                    array(
                                                    'key'       => 'Price',
                                                    'type'      => 'NUMERIC',
                                                    'value'     => $minprice,
                                                    'compare'   => '>'
                                                    ),
                                                    array(
                                                    'key'       => 'Price',
                                                    'type'      => 'NUMERIC',
                                                    'value'     => 0,
                                                    'compare'   => '>'
                                                    )                                                           
)
),
                array(
                'relation'      => 'AND',
                                        array(
                                        'relation'      => 'OR',
                                                    array(
                                                    'key'       => 'type',
                                                    'value'     => $type,
                                                    'compare'   => '='
                                                    ),
                                                    array(
                                                    'key'       => 'type',
                                                    'value'     => $type1,
                                                    'compare'   => '='
                                                    ),
                                                    array(
                                                    'key'       => 'type',
                                                    'value'     => $type2,
                                                    'compare'   => '='
                                                    )   ,   
                                                    array(
                                                    'key'       => 'type',
                                                    'value'     => $type3,
                                                    'compare'   => '='
                                                    ),  
                                                    array(
                                                    'key'       => 'type',
                                                    'value'     => $type4,
                                                    'compare'   => '='
                                                    )                                                           
)
),

                array(
                'relation'      => 'AND',
                                        array(
                                        'relation'      => 'OR',
                                                    array(
                                                    'key'       => 'bedrooms',
                                                    'value'     => $bed,
                                                    'compare'   => '='
                                                    ),
                                                    array(
                                                    'key'       => 'bedrooms',
                                                    'value'     => $bed1,
                                                    'compare'   => '='
                                                    ),
                                                    array(
                                                    'key'       => 'bedrooms',
                                                    'value'     => $bed2,
                                                    'compare'   => '='
                                                    ),
                                                    array(
                                                    'key'       => 'bedrooms',
                                                    'value'     => $bed3,
                                                    'compare'   => '='
                                                    ),
                                                    array(
                                                    'key'       => 'bedrooms',
                                                    'value'     => $bed4,
                                                    'compare'   => '='
                                                    ),
                                                    array(
                                                    'key'       => 'bedrooms',
                                                    'value'     => $bed5,
                                                    'compare'   => '='
                                                    ),
                                                    array(
                                                    'key'       => 'bedrooms',
                                                    'value'     => $bed6,
                                                    'compare'   => '='
                                                    ),
                                                    array(
                                                    'key'       => 'bedrooms',
                                                    'value'     => $bed7,
                                                    'compare'   => '='
                                                    ),
                                                    array(
                                                    'key'       => 'bedrooms',
                                                    'value'     => $bed8,
                                                    'compare'   => '='
                                                    ),                                                  
                                                    array(
                                                    'key'       => 'bedrooms',
                                                    'value'     => $bed9,
                                                    'compare'   => '='
                                                    ),
                                                    array(
                                                    'key'       => 'bedrooms',
                                                    'value'     => $bed10,
                                                    'compare'   => '='
                                                    ),                                                  
)
),

                array(
                'relation'      => 'AND',
                                        array(
                                        'relation'      => 'OR',
                                                    array(
                                                    'key'       => 'sale_or_rent',
                                                    'value'     => $salerent,
                                                    'compare'   => '='
                                                    ),
                                                    array(
                                                    'key'       => 'sale_or_rent',
                                                    'value'     => $saleorrent1,
                                                    'compare'   => '='
                                                    )                                                   
)
)


)
);



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

Код отображаемых сообщений PHP

 <div class="row" style="padding:0; margin:0;">
<ul id="starlistings" class="col-lg-12 col-md-12 row" >
<?php if( $the_query->have_posts() ): ?>
<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<li class="col-lg-6 col-md-6" style="float:left; ">
<div class="col-lg-12 col-md-12 listingframe" >
<div class="row" style="background-color:#77c0ff" "padding-top: 20px; padding-bottom: 20px">
<div class="text-center col-lg-12 col-md-12"><a class="listingslink" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
</div>
<div class="row" style="padding-top:0.8em;">
<div class="text-center col-lg-12 col-md-12" class="zero"><a href="<?php the_permalink(); ?>"><img src="<?php the_field('image_1'); ?>" class="w-100" alt="<?php the_field('image_1_alt'); ?>" title="<?php the_field('area_project'); ?> <?php $type = get_field('type'); if ($type=='Villa') echo 'House'; else { the_field('type');} ?> for <?php the_field('sale_or_rent'); ?> in Hua Hin"></a>

</div>

</div>
</div>
<div class="text-center listingsdivider col-lg-12 col-md-12">
    <span>
<span class="listingsicons" style="padding:5px 0.5em 5px 0;">ID #<?php the_field('property_id'); ?></span>
    <span class="listingsicons" style="padding:5px 0.5em 5px 0;"><?php $price = get_field('Price'); echo number_format($price, 0, '', ','); ?> baht<?php $saleorrent = get_field('sale_or_rent'); if($saleorrent=='Rent'){echo ' ';} ?></span>
<span class="listingsicons"  style="padding:5px 0.5em 5px 0.5em;"><img src="/wp-content/themes/startheme/images/house.png" alt="house" style="height:12px; width:auto; margin:-4px 8px 0 0; padding:0; opacity:0.7" /><?php the_field('living_space'); ?> SQM</span>
<span class="listingsicons" style="padding:5px 0.5em 5px 0.5em;"><img src="/wp-content/themes/startheme/images/beds.png" alt="bedrooms" style="height:12px; width:auto; margin:-2px 4px 0 -3px; padding:0; opacity:0.6" /><?php the_field('bedrooms'); ?> Beds</span>
    <span style="padding:5px 0 5px 0.5em; "><img src="/wp-content/themes/startheme/images/bathrooms.png" alt="bathrooms" style="height:15px; width:auto; margin:-2px 6px 0 2px; padding:0; opacity:0.6;" /><?php the_field('bathrooms'); ?> Baths</span>
    </span>

<div style="background-color: white; padding-top: 10px; padding-bottom: 5px"><span><?php $excerpt = wp_trim_words( get_field('property_description' ), $num_words = 10, $more = '<a href="'.get_permalink().'">... more</a>' ); echo $excerpt; ?></span></div>
</div>
     </li>

<?php endwhile; ?>
<?php endif; ?>
...