SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Member
    Join Date
    Feb 2012
    Location
    Brazil
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How to add link inside a query_posts function

    Hi guys, iam very new at developing wordpress theme, i learned alot reading the book HOW TO BUILD A WICKED WORDPRESS THEME, so i just started my first magazine theme, and since i dont really know PHP, i having a problem to add a link inside a function, so far i have this function:

    Code:
    function takecat3() {
    	query_posts( array ( 'posts_per_page' =>3, 'cat' => 3 ));
    	while ( have_posts() ) : the_post();
    	echo '<div class="cabelobox">';
    	the_post_thumbnail( 'foto-inicial' );
            the_title();
    	echo '</div>';
    	endwhile;
    	wp_reset_query();
    }

    It grabs the Featured Image, and the TITLE of the 3 last posts on category with the ID = 3, and its working, but i want to add a link into the image and title of the post, but i really dont know how to do that, i familiarized with the_permalink(), but i dont know how to put it in a way that it works, with anybody knows how to do that, i would appreciate alot, thanks!

  2. #2
    SitePoint Member
    Join Date
    Feb 2012
    Location
    Brazil
    Posts
    7
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    This is the third place, i post that same question, but after think for a while a managed to solve my own problem, this was the solution that i found:

    Code:
    query_posts( array ( 'posts_per_page' =>3, 'cat' => 3 ));
    	while ( have_posts() ) : the_post();
    	echo '<div class="cabelobox">';
    	echo '<a href="';
    	the_permalink();
    	echo '">';
    	the_post_thumbnail( 'foto-inicial' );
        the_title();
    	echo '</a>';
    	echo '</div>';
    	endwhile;
    	wp_reset_query();
    So, thanks anyway!


Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •