Search for posts with specific tag inside custom page template
-
I’m developing a WordPress blog where there are two custom pages – i.e., different from index.php. In there, there are two albums of photos, with the photos listed on a div above.
I’ve put an input so the user can type a tag and when he submits it, it will show on the album only the images of that specific tag.
The problem is that no matter what I put in the ‘action’ parameter of my input, it considers the action as ‘http://wordpressblogname.com/?name-of-my-input=value-of-my-input. That way, it searches on the index. I want it to search on the custom page that I created, so the search tag can filter the posts (images) from that page.
Can someone tell me how can I make it search on that custom page? Thanks.
Edit: Someone asked for the code. There it is:
<?php
$permalink = get_permalink( 55 );
?>
<form method=”get” action=”<?php echo $permalink; ?>”>
<input type=”text” name=”tag” value=”Procurar” onfocus=”if (this.value==’Procurar’) this.value = ”” onblur=”if (this.value==”) this.value=’Procurar’;”/>
</form><div class=”bottom-aluno”>
<?php
$args = array(
‘cat’ => 2,
‘tag’ => $_GET[‘tag-name’],
);$wp_query = new WP_Query($args);
$size = array(162,171);
if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php $src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID),”, false, ” ); ?>
” data-lightbox=”imagens-alunos”> <?php the_post_thumbnail(”, array(‘class’=>’universo-alunos-thumb’)); ?><?php endwhile; endif; ?>
</div>
- The topic ‘Search for posts with specific tag inside custom page template’ is closed to new replies.