use limit words with IF statement
-
I want to use an if statement with the limit word function:
Limit Word function code:
function string_limit_words($string, $word_limit) { $words = explode(' ', $string, ($word_limit + 1)); if(count($words) > $word_limit) array_pop($words); return implode(' ', $words); }
If statement I want to use:
if ( get_post_type() == "page" && string_limit_words < 14 ) {?> <a> " title="<?php the_title(); ?>"><img src="<?php echo get_stylesheet_directory_uri() ?>/images/page-icn.png" class="blog-icn" title="Read More" width="32" height="32"/><h2 class="blog-title"><?php the_title();?></h2></a> <?php }
PROBLEM IS:
This does not work within an if statement"string_limit_words < 14"
The point of all of this is to limit the post title text in search and blog pages.
Does the word limit function have something to call like the character limit function does:
(strlen($post->post_title) > 57 )
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- The topic ‘use limit words with IF statement’ is closed to new replies.