Web ページのソースをブラウザーで表示すると、ページの 1 つのセクションの周りに空白がたくさん表示されます。これを防ぐことはできないようです。以下は私が使用しているコードです。
html ページで呼び出される関数:
function query_single($posttype, $poststatus, $paidvalue, $taxtype, $value) {
/* Custom Query for a state, county, or city to display dentist with a single taxonomy query. This displays the results of the loop in taxonomy-dealercity.php, taxonomy-dealerstate.php, taxonomy-dealercounty.php, taxonomy-auctioncity.php, taxonomy-auctionstate.php, taxonomy-auctioncounty.php */
global $wp_query;
$wp_query = new WP_Query();
$args = array(
'post_type' => $posttype,
'post_status' => array($poststatus),
'orderby' => 'rand',
'posts_per_page' => 30,
'meta_query' => array(
array(
'key' => 'wpcf-paid',
'value' => array($paidvalue),
'compare' => 'IN',
)
),
'tax_query' => array(
array(
'taxonomy' => $taxtype,
'field' => 'slug',
'terms' => $value
)
)
);
return $wp_query->query($args);
}
html と php を含む taxonomy-state.php ページ:
<div class="co7">
<?php /*Based on type of page a custom h1 and page text is shown*/
echo "<h1 class=\"title\">$geo_no_dash Destist - Find a Dentist in $geo_no_dash</h1>";
echo "<p><small>Search for Dentist in $geo_no_dash with our comprehensive $geo_no_dash Dentist catalog. Find a Dentist in $geo_no_dash by city, state, county</small></p>";?>
<?php
/* This function found in the themes function.php file gets dentist which are used in the first wordpress loop which will show only paid dentist. */
query_single('dealers', 'publish', '1', $taxtype, $value);
?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php /* Retrieve relevant dentist information with get_post_meta. Function get_dealer_brands gets each dentist brands via a function added in the theme function.php file. Last section echos out dentist listings.*/
$address=get_post_meta($post->ID, 'wpcf-street_address', TRUE);
$city=get_post_meta($post->ID, 'wpcf-city', TRUE);
$state=get_post_meta($post->ID, 'wpcf-state_abbreviation', TRUE);
$zip=get_post_meta($post->ID, 'wpcf-zip_code', TRUE);
$phone=get_post_meta($post->ID, 'wpcf-phone_number', TRUE);
$paid=get_post_meta($post->ID, 'wpcf-paid', TRUE);
get_each_dealer_brand()?>
<ul class="ullisting">
<?php if($paid==1)
{
echo "<li><p class=\"plisting\"><strong><a href=\"";the_permalink(); echo "\">";the_title();echo "</a></strong></p></li>";
echo "<li><p class=\"plisting\">$address | $city, $state $zip</p></li>";
echo "<li><p class=\"plisting\">P: $phone</p></li>";
echo "<li><p class=\"listing\"><span><small>$brands_list</small></span></p></li>";
}?>
</ul>
ブラウザーの空白はそれぞれの間 ul class="ullisting
にあり、ブラウザーでソースを表示すると 4 ~ 7 行の空白になります。
ワードプレスのインストールを再構築しているため、現在ライブの例はありません。しかし、ここに私が得ていた出力があります:
<pre><code>
<!--Start Side Left Co7-->
<div class="co7">
<h1 class="title">Texas Dentist - Find Dentist in Texas</h1><p><small>Search for a Dentist in Texas with our comprehensive Dentist catalog.</small></p>
<ul class="ullisting">
<li><p class="plisting"><strong><a href="http://www.test.com/dealers/dentist1/">Dentist 1</a></strong></p></li><li><p class="plisting">g | g, g g</p></li><li><p class="plisting">P: h</p></li><li><p class="listing"><span><small>Gosmile</small></span> </p></li></ul>
<ul class="ullisting">
<li><p class="plisting"><strong>Dentist 2</strong></p></li><li><p class="plisting">26 main | Spring, TX 77090</p></li><li><p class="plisting">P: 7146122454</p></li><li><p class="listing"><span><small>Brightsmile</small></span></p></li></ul>
<ul class="ullisting">
<li><p class="plisting"><strong>Dentist 3</strong></p></li><li><p class="plisting">35 Main st | Houston, Tx 777090</p></li><li><p class="plisting">P: 1</p></li><li><p class="listing"><span><small>Pro Whitening</small></span></p></li></ul>