admin管理员组文章数量:1130349
I would greatly appreciate some help, I have written a loop inside a list item however I'm looking to set a width and height on the thumbnail and display some expert "text" but limit the length of it...
<ul>
<!-- Define our WP Query Parameters -->
<?php $the_query = new WP_Query( 'posts_per_page=3' ); ?>
<!-- Start our WP Query -->
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<li>
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail('large');
}
?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
</li>
<!-- Repeat the process and reset once it hits the limit -->
<?php
endwhile;
wp_reset_postdata();
?>
</ul>
I would greatly appreciate some help, I have written a loop inside a list item however I'm looking to set a width and height on the thumbnail and display some expert "text" but limit the length of it...
<ul>
<!-- Define our WP Query Parameters -->
<?php $the_query = new WP_Query( 'posts_per_page=3' ); ?>
<!-- Start our WP Query -->
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<li>
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail('large');
}
?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
</li>
<!-- Repeat the process and reset once it hits the limit -->
<?php
endwhile;
wp_reset_postdata();
?>
</ul>
Share
Improve this question
asked Dec 23, 2018 at 19:26
Joshua CurtisJoshua Curtis
11 bronze badge
1
- Added a function expert length which has worked! however not sure about the thumbnail I know you can set sizes "large" etc however can I define the height and width? – Joshua Curtis Commented Dec 23, 2018 at 19:37
1 Answer
Reset to default 0Add this function in your functions.php for specific size of thumbnail
add_image_size( 'custom-size', 220, 180 );
and fetch custom-size image. For excerpt length use this function.
function wp_example_excerpt_length( $length ) {
return 30;
}
add_filter( 'excerpt_length', 'wp_example_excerpt_length');
I would greatly appreciate some help, I have written a loop inside a list item however I'm looking to set a width and height on the thumbnail and display some expert "text" but limit the length of it...
<ul>
<!-- Define our WP Query Parameters -->
<?php $the_query = new WP_Query( 'posts_per_page=3' ); ?>
<!-- Start our WP Query -->
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<li>
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail('large');
}
?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
</li>
<!-- Repeat the process and reset once it hits the limit -->
<?php
endwhile;
wp_reset_postdata();
?>
</ul>
I would greatly appreciate some help, I have written a loop inside a list item however I'm looking to set a width and height on the thumbnail and display some expert "text" but limit the length of it...
<ul>
<!-- Define our WP Query Parameters -->
<?php $the_query = new WP_Query( 'posts_per_page=3' ); ?>
<!-- Start our WP Query -->
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<li>
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it.
the_post_thumbnail('large');
}
?>
<a href="<?php the_permalink() ?>"><?php the_title(); ?></a>
</li>
<!-- Repeat the process and reset once it hits the limit -->
<?php
endwhile;
wp_reset_postdata();
?>
</ul>
Share
Improve this question
asked Dec 23, 2018 at 19:26
Joshua CurtisJoshua Curtis
11 bronze badge
1
- Added a function expert length which has worked! however not sure about the thumbnail I know you can set sizes "large" etc however can I define the height and width? – Joshua Curtis Commented Dec 23, 2018 at 19:37
1 Answer
Reset to default 0Add this function in your functions.php for specific size of thumbnail
add_image_size( 'custom-size', 220, 180 );
and fetch custom-size image. For excerpt length use this function.
function wp_example_excerpt_length( $length ) {
return 30;
}
add_filter( 'excerpt_length', 'wp_example_excerpt_length');
本文标签: phpWordPress Recent PostsLoop
版权声明:本文标题:php - WordPress Recent Posts - Loop 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://it.en369.cn/questions/1749071282a2311613.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。


发表评论