我正在使用compare theme和我面临的问题是tables
. 我创建了一个HTML表,当我转到视觉模式时,它似乎是正确的。
但当我预览/发布它时,我看不到该表。你可以检查一下here. 只有单元格的文本存在。
以下是的代码部分single-product.php
生成页面的文件。
<div class="comparison-text">
<h1 class="title"><?php echo stripslashes(get_the_title()); ?></h1>
<?php
// Check if has global product description ( also stored as post meta )
$q = "SELECT product_description FROM ".$wpdb->prefix."pc_products_custom WHERE product_id = ".$post->ID;
$result = $wpdb->get_results($q);
$content = $result[0]->product_description;
// If no global product description use default one.
if ($content == \'\'){
$q = "SELECT rel.id_feed, rel.id_product FROM ".$wpdb->prefix."pc_products_feeds_relationships rel JOIN ".$wpdb->prefix."pc_feeds fe ON rel.id_feed = fe.id WHERE rel.id_product = ".$merchants[0]->id_product." AND fe.feed_use_master_description = 1 AND fe.active = 1 LIMIT 1";
$results_f = $wpdb->get_row($q);
$results_desc;
if(!empty($results_f)){
$q = "SELECT slug FROM ".$wpdb->prefix."pc_products_merchants WHERE feed = ".$results_f->id_feed;
$results_s = $wpdb->get_row($q);
$q = "SELECT feed_product_desc FROM ".$wpdb->prefix."pc_products WHERE id_product = ".$results_f->id_product." AND id_merchant=\'".$results_s->slug."\' LIMIT 1";
$results_desc = $wpdb->get_row($q);
}
if (!empty($results_desc->feed_product_desc)){
$content = $results_desc->feed_product_desc;
} else {
$content = get_the_content();
$content = strip_tags($content);
}
}
$size = 3500;
if(strlen($content) > $size) {
while(isset($content[$size]) && $content[$size] != \' \') {
$size++;
}
$display_content = substr($content,0,$size).\'<span class="desc_more" style="display:none;">\'.substr($content,$size,strlen($content)).\'</span><span class="desc_etc">...</span> <a href="#" id="more_link" onclick="more(); return false;">\'.__(\'More\',\'framework\').\'</a>\';
$display_content .= \'\';
} else {
$display_content = $content;
}
?>
<?php echo $display_content; ?>
<!-- END .comparison-text -->
我不懂PHP,但我想
$display_content
正在跳过表。有谁知道这个问题的原因以及如何解决?我试过了
Easy-Table
和
Tablepress
插件,但它们也不起作用。
最合适的回答,由SO网友:Charles Clarkson 整理而成
无论何时$results_desc->feed_product_desc
为空,则使用帖子内容。否则,永远不会使用内容。
if (!empty($results_desc->feed_product_desc)){
$content = $results_desc->feed_product_desc;
} else {
$content = get_the_content();
$content = strip_tags($content);
}
无论何时使用post内容,都会剥离所有HTML标记。
$content = get_the_content();
$content = strip_tags($content);
要获取所有标记的完整内容,请仅使用第一行:
$content = get_the_content();