Forums

[resolved] Hyperlink Inside of Array (4 posts)

  1. tapkid113
    Member
    Posted 10 months ago #

    Hello,

    I'm in the middle of editing the WP Nivo Slider plugin (the free one) to customize the title. I am having the following problem, though:
    I want to link the title that is inside of $thumb_attr array, but I can't seem to figure it out. :/ I don't know much about PHP, so I am fumbling my way through this.

    The code for the plugin is as follows:

    <div id="slider">
    <?php
    	$category = get_option('wpns_category');
    	$n_slices = get_option('wpns_slices');
    ?>
    <?php query_posts( 'cat='.$category.'&posts_per_page='.$n_slices.'' ); if( have_posts() ) : while( 
    
    have_posts() ) : the_post(); ?>
    	<?php if(has_post_thumbnail()) : ?>
    	<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
    		<?php $thumb_attr = array(
    				'title' => '<h3>' . '<a href="THIS IS WHERE LINK SHOULD GO">' . get_the_title() . '</a>' . '</h3>' . '<h4>' . get_the_excerpt() . '</h4>'
    		); ?>
    		<?php the_post_thumbnail('featured-thumbnail', $thumb_attr );  ?>
    </a>
    	<?php endif ?>
    	<?php endwhile; endif;?>
    	<?php wp_reset_query();?>
    </div>
  2. tapkid113
    Member
    Posted 10 months ago #

    I should have mentioned this above, but using <a href="<?php the_permalink(); ?>"> didn't work. I figured that was because the code is already inside of a <?php ?> tag, though.

  3. alchymyth
    The Sweeper
    Posted 10 months ago #

    instead the_permalink() http://codex.wordpress.org/Function_Reference/the_permalink

    you would need to use get_permalink()
    http://codex.wordpress.org/Function_Reference/get_permalink
    to use the permalink in a string;

    example:

    <?php $thumb_attr = array(
    				'title' => '<h3>' . '<a href="' . get_permalink($post->ID) . '">' . get_the_title() . '</a>' . '</h3>' . '<h4>' . get_the_excerpt() . '</h4>'
    		); ?>

    in wordpress, for functions starting with the_ ,there are often equivalent functions to return a string, starting with get_ or get_the_ .

  4. tapkid113
    Member
    Posted 10 months ago #

    That worked perfect!

    Thank you so much!!!!! :D

Reply

You must log in to post.

About this Topic