0
我想創建一個短代碼複製的正常工作如下: -WordPress的 - 在簡碼的變量包括PHP
$currency = get_field('currency', 'options');
$args = array(
'posts_per_page'=> -1,
'post_type' => 'properties',
);
$featured_query = new WP_Query($args); ?>
<!-- Featured Properties -->
<h1 class="text-grey"><span class="xstrong">Featured</span> Properties</h1>
<div id="featured-properties">
<div class="container">
<?php if($featured_query->have_posts()): $property_increment = 0; ?>
<div id="featured-carousel" class="carousel slide" data-ride="carousel">
<!-- Wrapper for slides -->
<div class="carousel-inner row" role="listbox">
<?php while($featured_query->have_posts()) : $featured_query->the_post(); ?>
<?php if($property_increment==0 || $property_increment%3==0){ echo '<div class="item '.(($property_increment==0)?'active':'').'">'; } ?>
<div class="col-md-4 col-sm-6 col-xs-12 row">
<div class="property-wrapper">
<a href="<?php echo get_permalink(); ?>">
<div class="corner"></div><p class="corner-text"><?php the_field('house_status'); ?></p>
<?php the_post_thumbnail($featured_query->ID, ''); ?>
<div class="property-details">
<h5 class="property-title"><?php the_title(); ?>,</h5>
<h6 class="property-title"><?php the_field('house_town'); ?></h6>
<h6 class="property-type"><?php the_field('house_type'); ?></h6>
<?php $price = number_format(get_field('house_price')); ?>
<h5 class="property-price"><?php echo $currency . $price; ?></h5>
<h5 class="property-bedrooms"><?php the_field('house_bedrooms'); ?><span class="icon-bedrooms"></span></h5>
<h5 class="property-bathrooms"><?php the_field('house_bathrooms'); ?><span class="icon-bathrooms"></span></h5>
<span class="btn btn-white full">More Details</span>
</div>
</a>
</div>
</div>
<?php echo ($property_increment%3==2)?'</div>':''; ?>
<?php $property_increment++; endwhile; ?>
</div>
<!-- Left and right controls -->
<a class="left carousel-control" href="#featured-carousel" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
<span class="sr-only">Previous</span>
</a>
<a class="right carousel-control" href="#featured-carousel" role="button" data-slide="next">
<span class=" glyphicon-chevron-right" aria-hidden="true"></span>
<span class="sr-only">Next</span>
</a>
</div>
<?php endif; wp_reset_query(); ?>
</div>
</div><!--/Featured Properties -->
我的問題是,當我嘗試創建這是一個簡碼,你不能使用回聲,如果,在變量中,我認爲它現在幾乎在那裏,我只是不知道我需要改變以實現它的工作,例如,我做什麼將'while'和'endif'替換爲I我在一個變量中使用它?
這是我到目前爲止有: -
/**
* Shortcode: Latest Properties
*/
function latest_content_properties_func($atts) {
$currency = get_field('currency', 'options');
$args = array(
'posts_per_page'=> -1,
'post_type' => 'properties',
);
$featured_query = new WP_Query($args);
$featured_content_properties = '';
$featured_content_properties = '<div id="featured-properties">';
$featured_content_properties .= '<div class="container">';
$featured_content_properties .= ($featured_query->have_posts()) . $property_increment = 0;
$featured_content_properties .= '<div id="featured-carousel" class="carousel slide" data-ride="carousel">';
$featured_content_properties .= '<div class="carousel-inner row" role="listbox">';
$featured_content_properties .= while($featured_query->have_posts()) : $featured_query->the_post();
$featured_content_properties .= ($property_increment==0 || $property_increment%3==0) . '<div class="item '.(($property_increment==0)?'active':'').'">';
$featured_content_properties .= '<div class="col-md-4 col-sm-6 col-xs-12 row">';
$featured_content_properties .= '<div class="property-wrapper">';
$featured_content_properties .= '<a href="'. get_permalink() .'">';
$featured_content_properties .= '<div class="corner"></div><p class="corner-text">'. get_field('house_status') .'</p>';
$featured_content_properties .= get_the_post_thumbnail($featured_query->ID, "");
$featured_content_properties .= '<div class="property-details">';
$featured_content_properties .= '<h5 class="property-title">'. get_the_title() .',</h5>';
$featured_content_properties .= '<h6 class="property-title">'. get_field('house_town') .'</h6>';
$featured_content_properties .= '<h6 class="property-type">'. get_field('house_type') .'</h6>';
$featured_content_properties .= $price = number_format(get_field("house_price"));
$featured_content_properties .= '<h5 class="property-price">'. $currency . $price .'</h5>';
$featured_content_properties .= '<h5 class="property-bedrooms">'. get_field('house_bedrooms') .'<span class="icon-bedrooms"></span></h5>';
$featured_content_properties .= '<h5 class="property-bathrooms">'. get_field('house_bathrooms') .'<span class="icon-bathrooms"></span></h5>';
$featured_content_properties .= '<span class="btn btn-white full">More Details</span>';
$featured_content_properties .= '</div>';
$featured_content_properties .= '</a>';
$featured_content_properties .= '</div>';
$featured_content_properties .= '</div>';
$featured_content_properties .= ($property_increment%3==2)? '</div>':'';
$featured_content_properties .= $property_increment++; endwhile;
$featured_content_properties .= '</div>';
$featured_content_properties .= '<a class="left carousel-control" href="#featured-carousel" role="button" data-slide="prev">';
$featured_content_properties .= '<span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>';
$featured_content_properties .= '<span class="sr-only">Previous</span>';
$featured_content_properties .= '</a>';
$featured_content_properties .= '<a class="right carousel-control" href="#featured-carousel" role="button" data-slide="next">';
$featured_content_properties .= '<span class=" glyphicon-chevron-right" aria-hidden="true"></span>';
$featured_content_properties .= '<span class="sr-only">Next</span>';
$featured_content_properties .= '</a>';
$featured_content_properties .= '</div>';
$featured_content_properties .= endif; wp_reset_query();
$featured_content_properties .= '</div>';
$featured_content_properties .= '</div>';
return $featured_content_properties;
}
add_shortcode('latest_content_properties', 'latest_content_properties_func');
任何幫助將不勝感激!