Forum Replies Created

Viewing 7 replies - 1 through 7 (of 7 total)
  • Thread Starter shuttleuk

    (@shuttleuk)

    That’s incredible helpful thank you so much

    Very best wishes, Sam

    Thread Starter shuttleuk

    (@shuttleuk)

    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 ??

    Thread Starter shuttleuk

    (@shuttleuk)

    Thanks 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

    Thread Starter shuttleuk

    (@shuttleuk)

    Below 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

    Thread Starter shuttleuk

    (@shuttleuk)

    Just 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; ?>
    Thread Starter shuttleuk

    (@shuttleuk)

    Thats 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.

    Thread Starter shuttleuk

    (@shuttleuk)

    Sorry, 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.

Viewing 7 replies - 1 through 7 (of 7 total)