• This should be easy and I don’t know if I’m having a moment or overthinking it – but I post a whole lot of events using their date as the title like 25th Wednesday 2011 – just in diff. categories.

    Of course when posted only the first gets that slug – the rest get appended with -1, -2, -3 etc.

    So I wanted to display all the posts with todays title in the sidebar.

    <?php
    	$today = date ("l jS F Y"); ?>
    <?php $daysracing = new WP_Query("name=$today&posts_per_page=-1"); while($daysracing->have_posts()) : $daysracing->the_post();
    $category = get_the_category(); ?>

    But of course because name works on the slug this is only showing the first post not the ones appended -1 and -2 etc.

    I can’t find a way to query the actual post title – so how do I get around this?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter ozpoker

    (@ozpoker)

    Anyone?

    Hey Oz, sorry to get your hopes up…I don’t have an answer, but have the same question, and was wondering if you could post your answer if you powered through this. Seems like there should be a built-in, something similar to the_author_posts_link, but I have yet to find it.

    Thread Starter ozpoker

    (@ozpoker)

    It’s not elegant but this was my solution based on titles with todays date:

    <?php date_default_timezone_set('Australia/Melbourne');
    	$today = date ("l jS F Y");
    	$today1 = date ("l jS F Y") . "-1";
    	$today2 = date ("l jS F Y") . "-2";
    	$today3 = date ("l jS F Y") . "-3";
    	$today4 = date ("l jS F Y") . "-4";
    	$today5 = date ("l jS F Y") . "-5";
    	$today6 = date ("l jS F Y") . "-6";
    	$today7 = date ("l jS F Y") . "-7";
    	$today8 = date ("l jS F Y") . "-8";
    	$today9 = date ("l jS F Y") . "-9";
    	$today10 = date ("l jS F Y") . "-10";
    	$today11 = date ("l jS F Y") . "-11";
    ?>
    
    				<h2><center>Todays Events - <?php echo $today ;?></center></h2>
    <br/>
    				<?php $daysracing = new WP_Query("name=$today&posts_per_page=-1"); while($daysracing->have_posts()) : $daysracing->the_post();
    				$category = get_the_category(); ?>
    				<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $category[0]->name; ?> for <?php the_title(); ?></a></li></ul>
    				<div style="clear:both;"></div>
    				<?php endwhile; ?>
    				<?php $daysracing = new WP_Query("name=$today1&posts_per_page=-1"); while($daysracing->have_posts()) : $daysracing->the_post();
    				$category = get_the_category(); ?>
    				<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $category[0]->name; ?> for <?php the_title(); ?></a></li></ul>
    				<div style="clear:both;"></div>
    				<?php endwhile; ?>
    				<?php $daysracing = new WP_Query("name=$today2&posts_per_page=-1"); while($daysracing->have_posts()) : $daysracing->the_post();
    				$category = get_the_category(); ?>
    				<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $category[0]->name; ?> for <?php the_title(); ?></a></li></ul>
    				<div style="clear:both;"></div>
    				<?php endwhile; ?>
    				<?php $daysracing = new WP_Query("name=$today3&posts_per_page=-1"); while($daysracing->have_posts()) : $daysracing->the_post();
    				$category = get_the_category(); ?>
    				<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $category[0]->name; ?> for <?php the_title(); ?></a></li></ul>
    				<div style="clear:both;"></div>
    				<?php endwhile; ?>
    				<?php $daysracing = new WP_Query("name=$today4&posts_per_page=-1"); while($daysracing->have_posts()) : $daysracing->the_post();
    				$category = get_the_category(); ?>
    				<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $category[0]->name; ?> for <?php the_title(); ?></a></li></ul>
    				<div style="clear:both;"></div>
    				<?php endwhile; ?>
    				<?php $daysracing = new WP_Query("name=$today5&posts_per_page=-1"); while($daysracing->have_posts()) : $daysracing->the_post();
    				$category = get_the_category(); ?>
    				<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $category[0]->name; ?> for <?php the_title(); ?></a></li></ul>
    				<div style="clear:both;"></div>
    				<?php endwhile; ?>
    				<?php $daysracing = new WP_Query("name=$today6&posts_per_page=-1"); while($daysracing->have_posts()) : $daysracing->the_post();
    				$category = get_the_category(); ?>
    				<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $category[0]->name; ?> for <?php the_title(); ?></a></li></ul>
    				<div style="clear:both;"></div>
    				<?php endwhile; ?>
    				<?php $daysracing = new WP_Query("name=$today7&posts_per_page=-1"); while($daysracing->have_posts()) : $daysracing->the_post();
    				$category = get_the_category(); ?>
    				<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $category[0]->name; ?> for <?php the_title(); ?></a></li></ul>
    				<div style="clear:both;"></div>
    				<?php endwhile; ?>
    				<?php $daysracing = new WP_Query("name=$today8&posts_per_page=-1"); while($daysracing->have_posts()) : $daysracing->the_post();
    				$category = get_the_category(); ?>
    				<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $category[0]->name; ?> for <?php the_title(); ?></a></li></ul>
    				<div style="clear:both;"></div>
    				<?php endwhile; ?>
    				<?php $daysracing = new WP_Query("name=$today9&posts_per_page=-1"); while($daysracing->have_posts()) : $daysracing->the_post();
    				$category = get_the_category(); ?>
    				<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $category[0]->name; ?> for <?php the_title(); ?></a></li></ul>
    				<div style="clear:both;"></div>
    				<?php endwhile; ?>
    				<?php $daysracing = new WP_Query("name=$today10&posts_per_page=-1"); while($daysracing->have_posts()) : $daysracing->the_post();
    				$category = get_the_category(); ?>
    				<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $category[0]->name; ?> for <?php the_title(); ?></a></li></ul>
    				<div style="clear:both;"></div>
    				<?php endwhile; ?>
    				<?php $daysracing = new WP_Query("name=$today11&posts_per_page=-1"); while($daysracing->have_posts()) : $daysracing->the_post();
    				$category = get_the_category(); ?>
    				<ul><li><a href="<?php the_permalink() ?>" rel="bookmark"><?php echo $category[0]->name; ?> for <?php the_title(); ?></a></li></ul>
    				<div style="clear:both;"></div>
    				<?php endwhile; ?>
Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Display all posts with the same title’ is closed to new replies.