CincinnatiKid
Forum Replies Created
-
Forum: Themes and Templates
In reply to: [Spacious] Post PreviewsHi! Try adding this snippet of code to your theme’s functions.php file:
function short_excerpt($num) { $limit = $num+1; $excerpt = str_split(get_the_excerpt()); $length = count($excerpt); if ($length>=$num) { $excerpt = array_slice( $excerpt, 0, $num); $excerpt = implode("",$excerpt)."…"; echo $excerpt; } else { the_excerpt(); } }
The snippet above includes a new function called
short_excerpt()
. Instead of using<?php the_excerpt() ?>
at lines 46-48 of the Spacious content.php file, you can now use the newshort_excerpt()
function and your desired character limit. For example, if you want to limit your excerpt to 25 characters the code would look like this:<?php short_excerpt(25); ?>
Forum: Themes and Templates
In reply to: [Theme: Senna] Problem with centering featured imageHi! Try adding this snippet of code to your theme’s style.css file:
a img.entry-featured-image { display: block; margin-left: auto; margin-right: auto; }
I don’t think it serves a purpose at all, because the
elseif
block of code will never be executed.The reason is that
is_singular
returns TRUE if any of the following returns TRUE:is_single()
,is_page()
oris_attachment()
. Therefore, the code will enter theif
block even if!is_page()
(in other words, the flow of control will enter theif
block even if theelseif
test case returns TRUE). Since it enters theif
block, the flow of execution will then bypass theelseif
test.My guess is that whoever wrote the function meant to write the
if
test asif ( is_single () ) { }
and not asif ( is_singular() ) { }