Support » Themes and Templates » link post tittle to post detail

  • hi,
    i m calling my post by category, i m calling only title and thumbnail, i want to do that when some one click on title it show post detail in next page , i m using the code below but its not working :

Viewing 8 replies - 1 through 8 (of 8 total)
  • <?php
    
    		//The Query
    $query = new WP_Query( 'category_name=small eham khabreen&posts_per_page=12' );
    
    echo '<ul>';
     //The Loop
    while ( $query->have_posts() ) : $query->the_post();
    	echo '<li>';
    	$queried_post = get_post($cat_id);
    	echo '<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>';
    	echo '</li>';
    endwhile;
    echo '</ul>';
    
    		?><code></code>

    can anyone tell what i m missing in my code …

    Michael

    (@alchymyth)

    Forum Moderator

    what is the resulting output of the posted code?

    http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters

    category_name needs to use the category slug;
    if this ‘small eham khabreen’ is one category, try:

    $query = new WP_Query( 'category_name=small-eham-khabreen&posts_per_page=12' );

    there is obviously no thumbnail code in your snippet.

    generally,
    the post title should be linked to the single post with the details (assuming your theme has a single.php template)

    also, you can remove this unrelated line:

    $queried_post = get_post($cat_id);

    its showing nothing in my colum ! just showing blank list :

    http://newsonline.com.pk/
    look at the bottom of “Addmision cell” for this posts result,

    i dnt have single.php page,

    yah i dnt use thumbnail in this column so i just want to link by title:

    any idea why its not showing result ?

    i m making single.php page, can you please tell me why the title is not showing in my list ??

    Michael

    (@alchymyth)

    Forum Moderator

    have you corrected the category_name query parameter?

    yes i have done it : here is the code,

    //The Query
    $query = new WP_Query( 'category_name=small-eham-khabreen&posts_per_page=12' );
    
    echo '<ul>';
     //The Loop
    while ( $query->have_posts() ) : $query->the_post();
    	echo '<li>';
    	echo '<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>';
    	echo '</li>';
    endwhile;
    echo '</ul>';

    boss problem solved 🙂 i made a silly mistake :p
    this is correct code 🙂

    //The Query
    $query = new WP_Query( 'category_name=small-eham-khabreen&posts_per_page=12' );
    
    echo '<ul>';
     //The Loop
    while ( $query->have_posts() ) : $query->the_post();
    	echo '<li>'; ?>
    	<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    	<?php echo '</li>';
    endwhile;
    echo '</ul>';

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘link post tittle to post detail’ is closed to new replies.