Support » Fixing WordPress » Custom Search Link

  • Resolved quasi

    (@quasi)


    Hi All,

    I’m trying to make a link that shows all posts with a certain TAG in a CATEGORY.

    I know how to do the query:

    $arrTag_cat = array('category_name' => media, 'tag' => video );
    query_posts( $arrTag_cat);
    if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
           		...
    	endwhile;
    endif;

    But I do not want the response on it on the page (here the sinlge.php). I just want an icon that when people click on it they have a page that opens with the related posts.

    Can someone help me? Or just give me a direction in which I have to dig.

    Thx a lot

Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter quasi

    (@quasi)

    maybe someone could explain me how the category page is generated on the server side so I could do a “tag in category” page…

    Thread Starter quasi

    (@quasi)

    Hi, me again.

    At the end I found a round about. Here is the code.

    <?php
    $myTag = aTag;						// Here comes the tag you need
    ?>
    <?php
    $display_categories = array(1,2,3,4,5);		// Here you put your Category IDs
    foreach ($display_categories as $frontcats) {
    ?>
    	<?php
    	$tagposts = get_posts("showposts=1&tag=$primez&cat=$frontcats");
    	foreach($tagposts as $post) : setup_postdata($post);
    	?>
    		<a href="<?php echo get_category_link($frontcats) . '&tag='. $myTag;?>"><?php $this_category = get_category($frontcats); ?><?php echo $this_category->cat_name; ?></a></h4>
    	<?php endforeach;  ?>
    <?php }  ?>

    For sure there must be a more server friendly code, bu tit’s all I could find/make up.

    It is using the category.php to render the results.

    have a nice day

    Thread Starter quasi

    (@quasi)

    ps: FOr sure you must think I crazy to speak to myself overhere, but I think this could serve someone else and avoid her/him the hours I’ve spend on it.

    Moderator Kathryn Presner

    (@zoonini)

    I think it’s awesome that you’ve posted your code for others to refer to in the future!

    If you would please mark this thread as “resolved” it would be appreciated. Helps everyone keep better track of whose issues are still outstanding. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Custom Search Link’ is closed to new replies.