shuttleuk
Forum Replies Created
-
That’s incredible helpful thank you so much
Very best wishes, Sam
Brilliant! thanks for the rapid reply.
And is it possible to somehow edit the “Filter” text on the button to “Search”, if I chose to keep it? Or would I have to use a css approach?
Thanks again ??
Forum: Hacks
In reply to: Loop query to display posts from same day as post being viewedThanks so much bcworkz and I hear what you’re saying.
Based on what you said I put together the follow:
<?php $args = array( 'date_query' => array( array( 'year' => $archive_year, 'month' => $archive_month, 'day' => $archive_day, ), ), 'posts_per_page'=> 1, 'category_name'=>'category2', );?> <?php $archive_query = new WP_Query( $args );while ($archive_query->have_posts()) : $archive_query->the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a> <?php endwhile; ?>
I must be messing up somewhere as it only lists the latest posts in category 2 rather than listing posts published on the same day as the current post. It’s also seems to knock out the loop I had in the sidebar which lists all articles in category 1. I checked the php error log, but it doesn’t provide me with any clues.
I’ll endeavour to read up on what you were saying. Thanks for the help though, much appreciated
Forum: Hacks
In reply to: Loop query to display posts from same day as post being viewedBelow is the pseudo code for what I’ve been trying:
Get current_post_date Perform wp_archive_query (where post_date = current_post_date & category = 2, showing only 1 post) Perform regular while loop query Output link to wp_archive_query result End while loop query
Any help would be greatly appreciated.
Cheers
Forum: Hacks
In reply to: Loop query to display posts from same day as post being viewedJust tried this, but not quite right.
<?php $pfx_date = get_the_date( $d, $post_id ); ?> <?php $archive_query = new WP_Query($pfx_date->get_the_date.'showposts=1'.'&category_name=category2');while ($archive_query->have_posts()) : $archive_query->the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><?php the_title(); ?></a> <?php endwhile; ?>
Forum: Hacks
In reply to: Loop query to display posts from same day as post being viewedThats great! Thanks Alchymyth, thats put me on the right path.
The only thing is, by following the example, it takes me to an archive page with posts from a particular day. As there is only going to be 1 other post on any given day I was hoping to create a direct link to it with a query. With what title I know of WordPress and php, I have put together a rough idea of the query that I wanted to perform.
<?php $archive_year = get_the_time('Y'); $archive_month = get_the_time('m'); $archive_day = get_the_time('d'); ?> <?php $archive_query = new WP_Query($archive_year, $archive_month, $archive_day,'showposts=1'.'&category_name=category2');while ($archive_query->have_posts()) : $archive_query->the_post(); ?> <a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title(); ?>"><h2>more from the author</h2></a> <?php endwhile; ?>
Excuse the syntax/formatting, I know that the above doesn’t do exactly what I want, but in theory is it possible to create a query like this, that would do what I want?
Many thanks again.
Forum: Hacks
In reply to: Loop query to display posts from same day as post being viewedSorry, I tried to edit the question but I was unable to. I have tried to reword the question to make more sense. Sorry for the confusion.
I would like to be able generate a link at the bottom of a post that displays links to other posts which were published on the same day. For example, if a users is reading a post in one category from 20th June 2014, I would like to be able to display links to all posts, from any category, that were posted on the same day.