I have the following written to retrieve a list of posts that match the title of the page, by their tag. The problem is it does not play nicely with tags that have multiple words (and perhaps special characters too but I have yet to run into that).
<?php $title_post_tag = new WP_Query( array( 'tag' => strtolower( get_the_title() ) ) ); while ( $title_post_tag->have_posts() ) : $title_post_tag->the_post(); ?> <p><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a> <?php the_date(); ?></p> <?php endwhile; ?>
I have read up on needing to sanitize in php but I'm not entirely sure how to use that in this context or if it would even help me at all.
Guidance is greatly appreciated.