php - How to get 5 words from database and put it in slider caption -
i'm trying write simple function 5 words table wp_posts , post_content row in wordpress , put in carousel caption:
<div class="caption"> <time class="the-date" datetime="<?php echo esc_attr(get_the_time('c')); ?>"> <?php echo esc_html(get_the_date()); ?></time> <h3><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <?php the_title(); ?></a></h3> <p>(here want put function)</p></div> and myqsql query
select substring_index(post_content," ",5) wp_posts `id`= (id_of_post) i need answering questions below
how post id , how put between <p> tags
now i'm having:
$getfewwords = $wpdb->get_var( "select substring_index(post_content,' ',8) wp_posts id = 1 and works , question how post id ?
solution below:
<?php $getfewwords = $wpdb->get_var( "select substring_index(post_content,' ',8) wp_posts `id`='$post->id' " ); echo "<h3>{$getfewwords}</h3>"; ?> hope helped somebody.
Comments
Post a Comment