WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] get the title from current loop of flexslider (4 posts)

  1. inspiredwp2013
    Member
    Posted 5 months ago #

    Hi i have this code of flexslider written in featureflexslider.php

    <?php
       // Get all sticky posts, but only sticky posts
       $sticky = get_option( 'sticky_posts' );
       $args = array(
            'numberposts' => 6, // Display up to 6 posts. Change at will
            'post__in'  => $sticky
             );
    	$postQuery = get_posts($args);
            foreach( $postQuery as $post ) : setup_postdata($post);
    
              if ( has_post_thumbnail() ) { ?>
    	    <li>
    		<a href="<?php echo get_permalink(); ?>" title="Go to <?           php echo the_title(); ?>" rel="bookmark">
    	       <?php the_post_thumbnail('feature-slider'); ?>
    		<p class="flex-caption"><?php the_title(); ?></p>
    
    		</a>
    	    </li>
    
        <?php}
    	endforeach; ?>

    now i want the current title of the flexslider to appear outside the <ul class='slides'> but i don't know how to do it. this is my code in my header.php file

    <div id="featured_posts">
      <div class="flexslider">
        <ul class="slides">
    
    	<?php get_template_part( 'featureflexslider' ); ?>
       </ul>
      </div>
        <?php //I WANT THE CURRENT POST TITLE TO APPEAR HERE ?>
    </div>
  2. bcworkz
    Member
    Posted 5 months ago #

    PHP has no way to know what the current title of the post being displayed is. This is the realm of javascript or jQuery. All you can do in PHP is provide a container in which a client side script can place the current title.

    The best way to get the current title would depend on how flexslider actually works. I'm afraid I have no idea aboout that.

  3. inspiredwp2013
    Member
    Posted 4 months ago #

    @bcworkz

    thanks for the information, somehow i managed to put a relative position in css that makes the title float outside the box. and added a z-index value higher than the box..

  4. bcworkz
    Member
    Posted 4 months ago #

    Ah! I see now, I misunderstood the question. I'm glad you got it sorted out, thanks for coming back and marking resolved.

Reply

You must log in to post.

About this Topic