php - 如何将特色内容放在商店内容下方

标签 php html css wordpress wordpress-theming

我有一些功能内容想放在我的商店内容之后,但是商店内容是在一个 php 文件中生成的,而功能内容是在 wordpress 页面中以静态 html 编写的。功能内容出现在商店内容之前,我需要切换它。

网页位于:http://www.bolistylus.com/shop/

这是当前页面的样子:

enter image description here

这是商店内容的 php 代码:

<?php
/**
 * Loop shop template
 *
 * DISCLAIMER
 *
 * Do not edit or add directly to this file if you wish to upgrade Jigoshop to newer
 * versions in the future. If you wish to customise Jigoshop core for your needs,
 * please use our GitHub repository to publish essential changes for consideration.
 *
 * @package    Jigoshop
 * @category   Catalog
 * @author     Jigowatt
 * @copyright  Copyright (c) 2011 Jigowatt Ltd.
 * @license    http://jigoshop.com/license/commercial-edition
 */
?>

<?php
global $columns, $per_page;

do_action('jigoshop_before_shop_loop');

$loop = 0;

if (!isset($columns) || !$columns) $columns = apply_filters('loop_shop_columns', 4);
//if (!isset($per_page) || !$per_page) $per_page = apply_filters('loop_shop_per_page', get_option('posts_per_page'));

//if ($per_page > get_option('posts_per_page')) query_posts( array_merge( $wp_query->query, array( 'posts_per_page' => $per_page ) ) );

ob_start();

if (have_posts()) : while (have_posts()) : the_post(); $_product = &new jigoshop_product( $post->ID ); $loop++;

    ?>
    <li class="product <?php if ($loop%$columns==0) echo 'last'; if (($loop-1)%$columns==0) echo 'first'; ?>">

        <?php do_action('jigoshop_before_shop_loop_item'); ?>

        <a href="<?php the_permalink(); ?>">

            <?php do_action('jigoshop_before_shop_loop_item_title', $post, $_product); ?>

            <strong><?php the_title(); ?></strong>

            <?php do_action('jigoshop_after_shop_loop_item_title', $post, $_product); ?>

        </a>

        <?php do_action('jigoshop_after_shop_loop_item', $post, $_product); ?>

    </li><?php

    if ($loop==$per_page) break;

endwhile; endif;

if ($loop==0) :

    echo '<p class="info">'.__('No products found which match your selection.', 'jigoshop').'</p>';

else :

    $found_posts = ob_get_clean();

    echo '<ul class="products">' . $found_posts . '</ul><div class="clear"></div>';

endif;

do_action('jigoshop_after_shop_loop');

这是功能内容的 html:

<div class="entry-content">
<h1 class="description-title">WHY IS BOLI BETTER?</h1>
<div class="feature feature-item-248"><img class="main" src="http://www.bolistylus.com/wp-content/uploads/uclaproduct.png" alt="" />
<div class="feature_description">
<div class="feature_description_header">
<h2 class="descript-heading">PERFECTLY WEIGHTED</h2>
</div>
<div class="feature_description_content">

Touch screens have simplified technology, but there has yet to be a way to capture the precision of a calligrapher or the stroke of an artist. Not only should it meet your needs, but a stylus should have style.

</div>
</div>
</div>
<div class="feature feature-item-252"><img class="main" src="http://www.bolistylus.com/wp-content/uploads/pinkproduct.png" alt="" />
<div class="feature_description">
<div class="feature_description_header">
<h2 class="descript-heading">PEN-LIKE PRECISION</h2>
</div>
<div class="feature_description_content">

Your stylus should be as sharp as your ideas. The thin and clear disc gives you the accuracy you want in a digital pen.

</div>
</div>
</div>
<div class="feature feature-item-254">

<img class="main" src="http://www.bolistylus.com/wp-content/uploads/blueproduct.png" alt="" />
<div class="feature_description">
<div class="feature_description_header">
<h2 class="descript-heading">BALL POINT</h2>
</div>
<div class="feature_description_content">

Hold your stylus at the angle you’re most comfortable with. Jot gives you the freedom to write or sketch like you’re used to.

</div>
</div>
</div>
<div class="feature feature-item-256">

<img class="main" src="http://www.bolistylus.com/wp-content/uploads/greenproduct.png" alt="" />
<div class="feature_description">
<div class="feature_description_header">
<h2 class="descript-heading">HEAVY METAL</h2>
</div>
<div class="feature_description_content">

Once Jot is in your grip, the quality is unmistakable. The durable aluminum and steel gives Jot superior conductivity and craftsmanship comparable to any luxury pen.

</div>
</div>
&nbsp;

</div>
</div>

最佳答案

此行创建产品列表:

echo '<ul class="products">' . $found_posts . '</ul><div class="clear"></div>';

这是商店的内容。如果您使用 Firebug 检查您的页面,您会注意到 ul.products,其中包含正在展示的 5 种产品(商店内容)。

之后要显示功能内容,您可以为静态数据创建一个 HTML 字符串并将其附加到上面的 echo 语句。例如。

$product_string = "";
$product_string = "<ul class='products'>" . $found_posts . "</ul><div class='clear'></div>";
$product_string .= "<div class='entry-content'><h1 class='description-title'>WHY IS BOLI BETTER?</h1>";

/* First Product */
$product_string .= "<div class='feature feature-item-248'><img class='main' src='http://www.bolistylus.com/wp-content/uploads/uclaproduct.png' alt='' /><div class='feature_description'><div class='feature_description_header'><h2 class='descript-heading'>PERFECTLY WEIGHTED</h2></div><div class='feature_description_content'>Touch screens have simplified technology, but there has yet to be a way to capture the precision of a calligrapher or the stroke of an artist. Not only should it meet your needs, but a stylus should have style.</div></div></div>";

$product_string .= "</div>";

同样,您可以为其他产品创建字符串并将它们附加到上面的字符串中。一旦你附加了所有的字符串,你只需要回显变量;

echo $product_string;

显然,这不是最巧妙的解决方案,但它应该可以完成工作。理想情况下,您还希望通过数据库提取您的功能内容。

此外,您可以创建一个函数,该函数根据传递给它的特征项 ID 检索相关信息。您可以遍历产品并调用函数来为您生成 HTML 字符串,而不必手动创建它们。

关于php - 如何将特色内容放在商店内容下方,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8799444/

相关文章:

php - 如何处理用户邮箱变更

PHP 和 MySQL - 何时启动网站

html - Bootstrap 3 - 从模态对话框中删除下划线

jquery - 如何增长一个圆圈来覆盖页面并成为菜单

javascript - 在函数中转换事件处理程序

php - 修复损坏的 libsodium php 安装 Ubuntu Xenial

php - 短标签是 php 中的好习惯吗?

javascript - 如何将 div 放置在旋转元素的顶部?

javascript - 如果没有内容可用,强制页脚到页面底部

html - Twitter Bootstrap 图片库未显示标题