WordPress.org

Forums

link post tittle to post detail (9 posts)

  1. fzishk
    Member
    Posted 2 years ago #

    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 :

  2. fzishk
    Member
    Posted 2 years ago #

    <?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 ...

  3. alchymyth
    Forum Moderator
    Posted 2 years ago #

    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);
  4. fzishk
    Member
    Posted 2 years ago #

    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 ?

  5. fzishk
    Member
    Posted 2 years ago #

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

  6. alchymyth
    Forum Moderator
    Posted 2 years ago #

    have you corrected the category_name query parameter?

  7. fzishk
    Member
    Posted 2 years ago #

    yes i have done it : here is the code,

  8. fzishk
    Member
    Posted 2 years ago #

    //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>';
  9. fzishk
    Member
    Posted 2 years ago #

    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>';

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.