该网站如下:http://smokingdesigners.com
我的网页砌体视图有问题。
我最近将我的主题更改为新主题,我的旧主题用于在每个文章上自动添加“更多”标签,以便裁剪我的文章以适应他们的砌体,所以我从未真正添加“更多” “超过1200篇文章中的标记。
我的新主题是裁剪文章很奇怪,导致我的页面搞砸了,因为一个盒子的高度可以说600(包括图片)而另一个450则看起来不太好。 (链接问题http://smokingdesigners.com/page/10/)
有没有办法制作一个高度为575的固定尺寸的盒子呢?
这是我的砌体主题代码..
$def_teaser_width = ( $dtw = get_option('wpb_post_teaser_width') ) ? $dtw : 'two-third';
if ( get_option('wpb_blog_layout') == __("Masonry", "wpb") ) {
$gallery_style = 'masonry';
} else {
$gallery_style = 'fluid';
}
if ( $_GET['style'] == 'masonry' ) {
$gallery_style = 'masonry';
} else if ( $_GET['style'] == 'fluid' ) {
$gallery_style = 'fluid';
}
$holder_class = ( $gallery_style == 'masonry' ) ? 'masonry_blocks' : 'float_blocks';
?>
<?php get_header(); ?>
<div class="float_blocks_container">
<div class="blog_teasers <?php echo $holder_class; ?>">
<?php if (have_posts()) :
$teasers_count = 0;
?>
<?php while (have_posts()) : the_post(); ?>
<?php
$teasers_count++;
$teaser_width = ( $tw = get_post_meta($post->ID, "_teaser_width", true) ) ? $tw : $def_teaser_width;
$teaser_width = ( $teaser_width == 'default' ) ? $def_teaser_width : $teaser_width;
//$teaser_width = ($teaser_w = get_post_meta($post->ID, "_teaser_width", true)) ? ' '.$teaser_w : ' one-half';
if ( $teaser_width == 'one-third' || ( $gallery_style == 'masonry' && $teaser_width == 'one-half' )) {
$th_w = 320;
$th_h = 180;
}
else if ( $teaser_width == 'one-half' ) {
$th_w = 495;
$th_h = 278;
}
else if ( $teaser_width == 'two-third' || ( $gallery_style == 'masonry' && $teaser_width == 'full-width' ) ) {
$th_w = 670;
$th_h = 377;
}
else if ( $teaser_width == 'full-width' ) {
$th_w = 1020;
$th_h = 574;
}
$content_type = (get_option('wpb_full_content') == 'true') ? ' full_content_in_blog' : '';
$has_thumbnail = '';
if (has_post_thumbnail() == false) { $has_thumbnail = ' no_thumbnail'; }
?>
<div id="post-<?php the_ID(); ?>" <?php post_class("post_teaser float_block ".$teaser_width.$has_thumbnail.$content_type); ?>>
<?php
$video_w = $th_w;
$video_h = $th_h;
$p_video = get_post_meta($post->ID, "_p_video", true);
$youtube = strpos($p_video, 'youtube.com');
$vimeo = strpos($p_video, 'vimeo');
if ( $youtube || $vimeo ) : ?>
<div class="p_video">
<?php
if ( $youtube ) {
preg_match('/[\\?\\&]v=([^\\?\\&]+)/', $p_video, $matches);
echo '<iframe width="'.$video_w.'" height="'.$video_h.'" src="http://www.youtube.com/embed/'.$matches[1].'" frameborder="0" allowfullscreen></iframe>';
}
else if ( $vimeo ) {
preg_match('#vimeo.com/([A-Za-z0-9\-_]+)?#s', $p_video, $matches);
echo '<iframe src="http://player.vimeo.com/video/'.$matches[1].'?title=0&byline=0&portrait=0" width="'.$video_w.'" height="'.$video_h.'" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>';
}
?>
</d
这是功能.PHP文件。
<?php
/*
wpb_category_filter
wpb_get_video_or_thumbnail
wpb_blog_pagination - previous/next page navigation
wpb_tags - return array with tags attached to post from specific vocab.
wpb_posted_under - return array with taxonomy object from specific vocab.
siteAttachedImages -
metaAttachedImages
wpb_login_head - changes logo in the WP login screen
wpb_resize - resize image to the specific dimensions
curPageURL - return current page url
*/
/* Category filter
---------------------------------------------------------- */
if (!function_exists('wpb_category_filter')) {
function wpb_category_filter ( $args = array() ) {
$defaults = array( 'taxonomy' => 'portfolio_category', 'posts' => NULL, 'echo' => true, 'filter_text' => __('Filter:', 'wpb_framework') );
$args = wp_parse_args( $args, $defaults );
$args = (object) $args;
if ( $args->posts == NULL) {
global $wp_query;
$args->posts = $wp_query->posts;
}
$categories_slugs_array = array();
$categories_names_array = array();
foreach ($args->posts as $p) {
$post_categories_array = wpb_get_post_categories(array('taxonomy' => $args->taxonomy, 'pid' => $p->ID));
if ( $post_categories_array ) {
$categories_slugs_array[$p->ID] = array();
$categories_names_array[$p->ID] = array();
if ( $post_categories_array['slug'] != NULL ) {
$categories_slugs_array[$p->ID] = array_unique( array_merge($post_categories_array['slug'], $categories_slugs_array[$p->ID]) );
$categories_names_array[$p->ID] = array_unique( array_merge($post_categories_array['name'], $categories_names_array[$p->ID]) );
}
}
}
$all_cats = array(); $all_slugs = array();
foreach ( $categories_names_array as $c ) { $all_cats = array_unique( array_merge( $all_cats, $c ) ); }
foreach ( $categories_slugs_array as $c ) { $all_slugs = array_unique( array_merge( $all_slugs, $c ) ); }
$filter = '';
if ( count($all_cats) > 0 ) :
$filter .= '<ul class="wpb_sort">';
$filter .= '<li class="wpb_all_cats"><span>'.$args->filter_text.'</span> <a class="wpb_sortable_current" href="#">'. __("All", "wpb_framework") .'</a></li>';
for ( $i = 0; $i < count($all_cats); $i++) {
$filter .= '<li><a class="wpb_sortable_cats" href="#" data-value="sortable-'.$all_slugs[$i].'">'.$all_cats[$i].'</a></li>';
}
$filter .= '</ul>';
unset($i);
endif;
return array('links' => $filter, 'categories_slugs_array' => $categories_slugs_array);
/*if ( $args->echo ) {
echo $filter;
} else {
return $filter;
}*/
}
}
/* Get video or thumbnail
---------------------------------------------------------- */
if (!function_exists('wpb_get_video_or_thumbnail')) {
function wpb_get_video_or_thumbnail( $args = array() ) {
$defaults = array( 'pid' => NULL, 'width' => 300, 'height' => 'proportional', 'force_image' => false, 'video_height' => 250, 'img_class' => NULL, 'echo' => true, 'before' => '', 'after' => '' );
$args = wp_parse_args( $args, $defaults );
$args = (object) $args;
if ($args->pid == NULL) {
global $post;
$pid = $post->ID;
} else {
$pid = $args->pid;
}
$has_thumbnail = '';
if ( has_post_thumbnail($pid) == false ) { $has_thumbnail = ' no_thumbnail'; }
$video_w = $args->width;
$video_h = $args->video_height;
$p_video = get_post_meta($pid, "_p_video", true);
$hide_image = get_post_meta($pid, "_hide_image", true);
$youtube = strpos($p_video, 'youtube.com');
$vimeo = strpos($p_video, 'vimeo');
if ( ($youtube || $vimeo) && !$args->force_image ) : ?>
<div class="p_video">
<?php
if ( $youtube ) {
preg_match('/[\\?\\&]v=([^\\?\\&]+)/', $p_video, $matches);
echo $args->before.'<iframe width="'.$video_w.'" height="'.$video_h.'" src="http://www.youtube.com/embed/'.$matches[1].'" frameborder="0" allowfullscreen></iframe>'.$args->after;
}
else if ( $vimeo ) {
preg_match('#vimeo.com/([A-Za-z0-9\-_]+)?#s', $p_video, $matches);
echo $args->before.'<iframe src="http://player.vimeo.com/video/'.$matches[1].'?title=0&byline=0&portrait=0" width="'.$video_w.'" height="'.$video_h.'" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>'.$args->after;
}
?>
</div>
<?php endif; ?>
<?php if ( ($has_thumbnail == '' && $hide_image != 'no' && $youtube == false && $vimeo == false)
|| $hide_image != 'no' && $args->force_image == true
) :
$th_id = get_post_thumbnail_id($pid);
$image_src = wp_get_attachment_image_src( $th_id, 'full' );
if ( $args->height == 'proportional' ) {
$th_h = round($video_w/$image_src[1] * $image_src[2]);
} else {
$th_h = $args->height;
}
$image = wpb_resize( $th_id, '', $video_w, $th_h, true );
$html = $args->before . '<img ';
$html .= ( $args->img_class ) ? ' class="'. $args->img_class .'"' : '';
$html .= ' src="'. $image['url'] .'" alt="" />'. $args->after;
if ($image['url'] && $args->echo) :
echo $html;
else:
return $html;
endif; ?>
<?php endif; ?>
<?php
}
}
/* Outputs next/previous links paginator
---------------------------------------------------------- */
if (!function_exists('wpb_next_prev_pagination')) {
function wpb_next_prev_pagination( $args = array() ) {
$defaults = array( 'next_txt' => '', 'prev_txt' => '', 'extra_class' => '' );
$args = wp_parse_args( $args, $defaults );
$args = (object) $args;
global $wp_query;
if ( $wp_query->max_num_pages > 1 ) :
if ($args->next_txt == '') $args->next_txt = '< ' . __('Previous posts', 'wpb_framework');
if ($args->prev_txt == '') $args->prev_txt = __('Next posts', 'wpb_framework') . ' >';
if ($args->extra_class != '') $args->extra_class = ' ' . $args->extra_class;
?>
<div class="wpb_paginator<?php echo $args->extra_class; ?>">
<?php next_posts_link($args->next_txt); previous_posts_link($args->prev_txt); ?><?php //previous == Se tidligere indlæg ?>
</div>
<?php
endif;
}
}
/* Paged paginator
---------------------------------------------------------- */
add_filter('previous_posts_link_attributes', 'previous_posts_link_css' );
function previous_posts_link_css($content) {
return 'class="controls left_control"';
}
add_filter('next_posts_link_attributes', 'next_posts_link_css' );
function next_posts_link_css($content) {
return 'class="right_control"';
}
if ( !function_exists('wpb_pagination') ) {
//Thanks Kriesi for the nice paginator
function wpb_pagination( $pages = '', $range = 10 ) {
$showitems = ($range * 2)+1;
//global $paged;
$paged = get_query_var('paged');
if ( empty($paged) ) $paged = 1;
if ( $pages == '' ) {
global $wp_query;
$pages = $wp_query->max_num_pages;
if ( !$pages ) {
$pages = 1;
}
}
if ( 1 != $pages ) {
echo "<div class='wp-pagenavi'>";
//if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>«</a>";
//if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹</a>";
for ( $i=1; $i <= $pages; $i++ ) {
if ( 1 != $pages && ( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems )) {
echo ( $paged == $i ) ? "<span class='current'>". $i ."</span>" : "<a href='". get_pagenum_link($i) ."' class='inactive' >". $i ."</a>";
}
}
if ($paged < $pages && $showitems < $pages) previous_posts_link('←');
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) next_posts_link('→');
//if ($paged < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($paged + 1)."'>›</a>";
//if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>»</a>";
echo "</div>\n";
}
}
}
/* Receives taxonomy name as argument and returns array
with tags objects
---------------------------------------------------------- */
if ( !function_exists('wpb_tags') ) {
function wpb_tags( $args = array() ) {
$defaults = array( 'pid' => NULL, 'tag_vocab' => '', 'echo' => true, 'before' => '', 'separator' => '', 'after' => '' );
$args = wp_parse_args( $args, $defaults );
$args = (object) $args;
if ($args->pid == NULL) {
global $post;
$pid = $post->ID;
} else {
$pid = $args->pid;
}
if ($args->tag_vocab != '') {
$output = get_the_term_list($pid, $args->tag_vocab, $args->before, $args->separator, $args->after);
} else {
$c_arr = array();
$tags_arr = get_the_tags();
if ($tags_arr) {
foreach($tags_arr as $tag) {
$c_arr[] = $args->before.'<a href="'.get_tag_link($tag->term_id).'" title="">' . $tag->name . '</a>'.$args->after;
}
$output = implode($args->separator, $c_arr);
}
}
if ($output and $args->echo) {
echo $output;
} else if ($output) {
return $output;
}
}
}
/*
---------------------------------------------------------- */
if (!function_exists('wpb_get_post_category_names')) {
function wpb_get_post_categories( $args = array() ) {
$defaults = array( 'taxonomy' => '', 'pid' => NULL, 'echo' => TRUE );
$args = wp_parse_args( $args, $defaults );
$args = (object) $args;
if ( $args->pid == NULL ) {
global $post;
$args->pid = $post->ID;
}
if ( $args->taxonomy != '' ) {
$terms = wp_get_object_terms($args->pid, $args->taxonomy);
}
if ( $terms ) {
$term_output = array();
$names = array();
$slugs = array();
foreach ( $terms as $term ) {
$names[] = $term->name;
$slugs[] = $term->slug;
}
$term_output['name'] = array_unique($names);
$term_output['slug'] = array_unique($slugs);
return $term_output;
}
}
}
/* Receives taxonomy name as argument and returns array
with taxonomy objects
---------------------------------------------------------- */
if (!function_exists('wpb_posted_under')) {
function wpb_posted_under( $args = array() ) {
$defaults = array( 'taxonomy' => '', 'pid' => NULL, 'echo' => TRUE, 'separator' => ', ', 'link' => TRUE );
$args = wp_parse_args( $args, $defaults );
$args = (object) $args;
if ($args->pid == NULL) {
global $post;
$args->pid = $post->ID;
}
if ($args->taxonomy != '') {
$terms = wp_get_object_terms($args->pid, $args->taxonomy);
}
else {
$terms = array();
foreach((get_the_category()) as $category) {
//get_category_link($category->cat_ID)
//$category->cat_name
$terms[] = $category;
}
}
if ($terms) {
$term_output = '';
foreach ($terms as $term) {
//$term_output[] = '<a href="'.get_category_link($term->term_id).'" title="' . $term->name . '">' . $term->name . '</a>';
if ($args->link) {
$term_output[] = '<a href="'.get_term_link($term).'" title="' . $term->name . '">' . $term->name . '</a>';
}
else {
$term_output[] = $term->name;
}
}
$term_output = implode($args->separator, $term_output);
if ($args->echo) {
echo $term_output;
}
else {
return $term_output;
}
}
}
}
/* Helper function which returs list of site attached images,
and if image is attached to the current post it adds class
'added'
---------------------------------------------------------- */
if (!function_exists('siteAttachedImages')) {
function siteAttachedImages($att_ids = array()) {
$output = '';
global $wpdb;
$media_images = $wpdb->get_results("SELECT * FROM $wpdb->posts WHERE post_type = 'attachment' order by ID desc");
foreach($media_images as $image_post) {
$thumb_src = wp_get_attachment_image_src($image_post->ID, 'thumbnail');
$thumb_src = $thumb_src[0];
$class = (in_array($image_post->ID, $att_ids)) ? ' class="added"' : '';
if ($thumb_src) {
$output .= '<li'.$class.'>
<img rel="'.$image_post->ID.'" src="'. $thumb_src .'" alt="'. $img_details[0] .'" />
<span class="img-added">'. __('Added', 'wpb_framework') .'</span>
</li>';
}
}
if ($output != '') {
$output = '<ul class="gallery_widget_img_select">' . $output . '</ul>';
}
return $output;
}
}
/* Helper function. Outputs attached images to the post
in custom meta section.
---------------------------------------------------------- */
if (!function_exists('metaAttachedImages')) {
function metaAttachedImages($att_ids = array()) {
$output = '';
foreach ($att_ids as $img_id) {
$thumb_src = wp_get_attachment_image_src($img_id, 'thumbnail');
$thumb_src = $thumb_src[0];
if ($thumb_src) {
$output .= '<li class="added">
<img rel="'.$img_id.'" src="'. $thumb_src .'" alt="" />
<span class="img-added">'. __('Added', 'wpb_framework') .'</span>
</li>';
}
}
return $output;
}
}
function getTopLevelCategories() {
$topCat = array();
$categories = get_categories('hide_empty=0');
foreach ($categories as $category) {
if ($category->parent == 0) {
$topCat[] = $category->name;
}
}
return $topCat;
}
/* Goldmines from internet
---------------------------------------------------------- */
/* Change Wordpress logo on login screen
---------------------------------------------------------- */
if (!function_exists('wpb_login_head')) {
add_action("login_head", "wpb_login_head");
function wpb_login_head() {
echo "
<style>
body.login #login h1 a {
background: url('".get_bloginfo('template_url')."/images/logotype.png') no-repeat scroll center top transparent;
}
</style>
";
}
}
/*
* Resize images dynamically using wp built in functions
* Victor Teixeira
*
* php 5.2+
*
* Exemplo de uso:
*
* <?php
* $thumb = get_post_thumbnail_id();
* $image = vt_resize( $thumb, '', 140, 110, true );
* ?>
* <img src="<?php echo $image[url]; ?>" width="<?php echo $image[width]; ?>" height="<?php echo $image[height]; ?>" />
*
* @param int $attach_id
* @param string $img_url
* @param int $width
* @param int $height
* @param bool $crop
* @return array
*/
if (!function_exists('wpb_resize')) {
function wpb_resize( $attach_id = null, $img_url = null, $width, $height, $crop = false ) {
// this is an attachment, so we have the ID
if ( $attach_id ) {
$image_src = wp_get_attachment_image_src( $attach_id, 'full' );
$file_path = get_attached_file( $attach_id );
// this is not an attachment, let's use the image url
} else if ( $img_url ) {
$file_path = parse_url( $img_url );
$file_path = $_SERVER['DOCUMENT_ROOT'] . $file_path['path'];
//$file_path = ltrim( $file_path['path'], '/' );
//$file_path = rtrim( ABSPATH, '/' ).$file_path['path'];
$orig_size = getimagesize( $file_path );
$image_src[0] = $img_url;
$image_src[1] = $orig_size[0];
$image_src[2] = $orig_size[1];
}
$file_info = pathinfo( $file_path );
$extension = '.'. $file_info['extension'];
// the image path without the extension
$no_ext_path = $file_info['dirname'].'/'.$file_info['filename'];
$cropped_img_path = $no_ext_path.'-'.$width.'x'.$height.$extension;
// checking if the file size is larger than the target size
// if it is smaller or the same size, stop right here and return
if ( $image_src[1] > $width || $image_src[2] > $height ) {
// the file is larger, check if the resized version already exists (for $crop = true but will also work for $crop = false if the sizes match)
if ( file_exists( $cropped_img_path ) ) {
$cropped_img_url = str_replace( basename( $image_src[0] ), basename( $cropped_img_path ), $image_src[0] );
$vt_image = array (
'url' => $cropped_img_url,
'width' => $width,
'height' => $height
);
return $vt_image;
}
// $crop = false
if ( $crop == false ) {
// calculate the size proportionaly
$proportional_size = wp_constrain_dimensions( $image_src[1], $image_src[2], $width, $height );
$resized_img_path = $no_ext_path.'-'.$proportional_size[0].'x'.$proportional_size[1].$extension;
// checking if the file already exists
if ( file_exists( $resized_img_path ) ) {
$resized_img_url = str_replace( basename( $image_src[0] ), basename( $resized_img_path ), $image_src[0] );
$vt_image = array (
'url' => $resized_img_url,
'width' => $proportional_size[0],
'height' => $proportional_size[1]
);
return $vt_image;
}
}
// no cache files - let's finally resize it
$new_img_path = image_resize( $file_path, $width, $height, $crop );
if ( is_string($new_img_path) == false ) { return ''; }
$new_img_size = getimagesize( $new_img_path );
$new_img = str_replace( basename( $image_src[0] ), basename( $new_img_path ), $image_src[0] );
// resized output
$vt_image = array (
'url' => $new_img,
'width' => $new_img_size[0],
'height' => $new_img_size[1]
);
return $vt_image;
}
// default output - without resizing
$vt_image = array (
'url' => $image_src[0],
'width' => $image_src[1],
'height' => $image_src[2]
);
return $vt_image;
}
}
/* Returns current page url
---------------------------------------------------------- */
function curPageURL() {
$pageURL = 'http';
if ($_SERVER["HTTPS"] == "on") { $pageURL .= "s"; }
$pageURL .= "://";
if ($_SERVER["SERVER_PORT"] != "80") {
$pageURL .= $_SERVER["SERVER_NAME"].":".$_SERVER["SERVER_PORT"].$_SERVER["REQUEST_URI"];
} else {
$pageURL .= $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"];
}
return $pageURL;
}
?>
---最后是MASONRY FLUID主题文件---
<?php
$def_teaser_width = ( $dtw = get_option('wpb_post_teaser_width') ) ? $dtw : 'two-third';
if ( get_option('wpb_blog_layout') == __("Masonry", "wpb") ) {
$gallery_style = 'masonry';
} else {
$gallery_style = 'fluid';
}
if ( $_GET['style'] == 'masonry' ) {
$gallery_style = 'masonry';
} else if ( $_GET['style'] == 'fluid' ) {
$gallery_style = 'fluid';
}
$holder_class = ( $gallery_style == 'masonry' ) ? 'masonry_blocks' : 'float_blocks';
?>
<?php get_header(); ?>
<div class="float_blocks_container">
<div class="blog_teasers <?php echo $holder_class; ?>">
<?php if (have_posts()) :
$teasers_count = 0;
?>
<?php while (have_posts()) : the_post(); ?>
<?php
$teasers_count++;
$teaser_width = ( $tw = get_post_meta($post->ID, "_teaser_width", true) ) ? $tw : $def_teaser_width;
$teaser_width = ( $teaser_width == 'default' ) ? $def_teaser_width : $teaser_width;
//$teaser_width = ($teaser_w = get_post_meta($post->ID, "_teaser_width", true)) ? ' '.$teaser_w : ' one-half';
if ( $teaser_width == 'one-third' || ( $gallery_style == 'masonry' && $teaser_width == 'one-half' )) {
$th_w = 320;
$th_h = 180;
}
else if ( $teaser_width == 'one-half' ) {
$th_w = 495;
$th_h = 278;
}
else if ( $teaser_width == 'two-third' || ( $gallery_style == 'masonry' && $teaser_width == 'full-width' ) ) {
$th_w = 670;
$th_h = 377;
}
else if ( $teaser_width == 'full-width' ) {
$th_w = 1020;
$th_h = 574;
}
$content_type = (get_option('wpb_full_content') == 'true') ? ' full_content_in_blog' : '';
$has_thumbnail = '';
if (has_post_thumbnail() == false) { $has_thumbnail = ' no_thumbnail'; }
?>
<div id="post-<?php the_ID(); ?>" <?php post_class("post_teaser float_block ".$teaser_width.$has_thumbnail.$content_type); ?>>
<?php
$video_w = $th_w;
$video_h = $th_h;
$p_video = get_post_meta($post->ID, "_p_video", true);
$youtube = strpos($p_video, 'youtube.com');
$vimeo = strpos($p_video, 'vimeo');
if ( $youtube || $vimeo ) : ?>
<div class="p_video">
<?php
if ( $youtube ) {
preg_match('/[\\?\\&]v=([^\\?\\&]+)/', $p_video, $matches);
echo '<iframe width="'.$video_w.'" height="'.$video_h.'" src="http://www.youtube.com/embed/'.$matches[1].'" frameborder="0" allowfullscreen></iframe>';
}
else if ( $vimeo ) {
preg_match('#vimeo.com/([A-Za-z0-9\-_]+)?#s', $p_video, $matches);
echo '<iframe src="http://player.vimeo.com/video/'.$matches[1].'?title=0&byline=0&portrait=0" width="'.$video_w.'" height="'.$video_h.'" frameborder="0" webkitAllowFullScreen allowFullScreen></iframe>';
}
?>
</div>
<?php endif; ?>
<?php if ( $has_thumbnail == '' && $youtube == false && $vimeo == false) : ?>
<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">
<?php
$th_id = get_post_thumbnail_id();
$image_src = wp_get_attachment_image_src( $th_id, 'full' );
$th_h = 220;
$image = wpb_resize( $th_id, '', $th_w, $th_h, true );
if ($image['url']) : ?>
<img class="post_teaser_img" src="<?php echo $image['url']; ?>" alt="" />
<?php endif; ?>
</a>
<?php endif; ?>
<div class="teaser_content">
<h2 class="post_title"><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<div class="post_info">
<span class="light"><?php _e("Posted by", "wpb"); ?></span> <?php the_author(); ?> <span class="light"><?php _e("in", "wpb"); ?></span> <?php wpb_posted_under(); ?> <span class="date"><span class="light"><?php _e("on ", "wpb"); ?></span><?php the_time('F j, Y'); ?></span>
</div>
<?php
if ($content_type == ' full_content_in_blog') {
the_content('');
} else {
the_excerpt('');
}
?>
</div> <!-- end .teaser_content -->
<div class="teaser_meta">
<a class="read_more" href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php _e("Read more...", "wpb"); ?></a>
<span class="comment_balloon"><?php comments_popup_link( __( 'Leave a comment', 'wpb' ), __( '1 Comment', 'wpb' ), __( '% Comments', 'wpb' ) ); ?></span>
<div class="social_buttons">
<?php echo do_shortcode('[vc_facebook type="button_count" url="'.get_permalink().'"]'); ?>
<?php echo do_shortcode('[vc_tweetmeme]'); ?>
</div>
<div class="wpb_clear"></div>
</div> <!-- end .teaser_ment -->
</div> <!-- end .post_teaser -->
<?php
endwhile;
endif;
?>
<?php if ( $teasers_count > 1 && $gallery_style != 'masonry') : ?>
<a id="float_prev" class="tooltip" title="<?php _e("Previous post", "wpb"); ?>"></a>
<a id="float_next" class="tooltip" title="<?php _e("Next post", "wpb"); ?>"></a>
<?php endif; ?>
<?php if ( $gallery_style != 'masonry' ) { wpb_pagination(); } ?>
<div class="wpb_clear"></div>
</div> <!-- end main_content -->
<?php
if ( $gallery_style == 'masonry' ) {
echo '<div class="masonry_paginator">';
wpb_pagination();
echo '</div>';
}
?>
<div class="wpb_clear"></div>
</div> <!-- end container_12 -->
<?php get_footer(); ?>
答案 0 :(得分:0)
您可以通过确保所有摘录(因为自动生成的简短介绍文本被调用)的长度相同来解决此问题。此外,这些摘录中还有HTML标记,如果您想要一致地使用空间,这不是一个好主意。所以,我们走了。
在您的主题functions.php
中,您应该添加以下内容:
function my_new_excerpt_length($length) {
return 20;
}
add_filter( 'excerpt_length', 'my_new_excerpt_length', 999 );
此处,my_new_excerpt_length
是您的功能的自定义名称。 20
是您希望摘录的单词数量。当然,您可以调整这些值。只需进行实验,直到满足您的需求为止。
注意:可能是在该特定页面上没有显示更改。请发布完整的模板,以便我可以看一下页面下方发生的事情。