Forum Replies Created

Viewing 15 replies - 1 through 15 (of 20 total)
  • Thread Starter Nith

    (@nith)

    Brilliant! Worked exactly as I hoped ??

    Ty.

    Thread Starter Nith

    (@nith)

    Well, that’s not really achievable as I need the functionality of wp_get_archives() in order to display a option box populated with the months/year of all my posts and how many posts are in each of these items.

    As far as I’m aware, this isn’t achievable with a custom query.

    Forum: Fixing WordPress
    In reply to: If Statement?
    Thread Starter Nith

    (@nith)

    Ah, get_the_time() is the function I was looking for ??

    if(get_the_time('F') == $filter['month'] && get_the_time('Y') == $filter['year']) {
    	// My code here
    }

    Worked great.

    Ty.

    Thread Starter Nith

    (@nith)

    Ah thanks for that:

    <?php get_post_meta($post_id, $key, $single); ?>

    …will do the job.

    Thread Starter Nith

    (@nith)

    Yeah, worked great.

    <div id="post-nav">
    	<p class="previous_post">
    		<?php if(get_adjacent_post(true, '', true)) { ?>
    			<b>Previous: </b> <?php previous_post_link('%link','%title',true); ?>
    		<?php } ?>
    	</p>
    	<p class="next_post">
    		<?php if(get_adjacent_post(true, '', false)) { ?>
    			<b> :Next</b> <?php next_post_link('%link','%title',true); ?>
    		<?php } ?>
    	</p>
    </div>

    Cheers.

    Forum: Fixing WordPress
    In reply to: Advanced Query
    Thread Starter Nith

    (@nith)

    Works like a charm ??

    Thanks so much for your help/patience, appreciate it.

    All the best.

    Forum: Fixing WordPress
    In reply to: Advanced Query
    Thread Starter Nith

    (@nith)

    Oops. Yeah, I forgot to update the original code.

    I’ve removed the echo 'List of Posts in '.$taxonomy .' '.$term->name; ?> line and also change line 'include'=> '3,4,11', to 'include'=> '3', to only return the posts in the ‘blog’ category.

    So, I’m aiming in having the output be:

    <li>
    post 1 in the category 'blog'
    post 2 in the category 'blog'
    </li>
    <li>
    post 3 in the category 'blog'
    post 4 in the category 'blog'
    </li>
    <li>
    post 5 in the category 'blog'
    post 6 in the category 'blog'
    </li>

    But it’s not happening. I’m guessing it’s because the ‘posts_per_page’ is set to 2, but removing that will just display all the posts in one <li> element right? And I want to ‘split’ the posts and have two of the posts in each element (like the output above).

    Sorry for the confusion, my bad.

    Forum: Fixing WordPress
    In reply to: Advanced Query
    Thread Starter Nith

    (@nith)

    Yeah, as I first thought, because I’ve moved the <li> tags outside the while loop, they are not getting duplicated (there is only ever one).

    This is where I was running into difficulty in the beginning. The <li> needs to be inside the while loop in order to get replicated, but the issue is displaying the ‘post_per_page‘ in each <li>.

    Forum: Fixing WordPress
    In reply to: Advanced Query
    Thread Starter Nith

    (@nith)

    Oh right.

    I have set the ‘posts_per_page‘ to 2 to test this and after trying what you said, only the first two posts are showing in each <li> element for some reason. The other posts in the category are not getting displayed (there are other posts in the category). https://www.nickythorne.com/pages/blog/

    I’ve pastebin’d the code: https://pastebin.com/j38kzsq1

    Thanks for your help.

    Forum: Fixing WordPress
    In reply to: Advanced Query
    Thread Starter Nith

    (@nith)

    Not quite.

    Lets say I want to display 15 posts altogether, then the ‘posts_per_page’ would be 15.

    Below is the functionality I’m looking for

    This would mean that i’d have 3 slides or <li> elements with 5 posts in each (making up the 15 altogether).

    I need the existing code to be there as I only want to select the posts from certain categories.

    Forum: Fixing WordPress
    In reply to: Advanced Query
    Thread Starter Nith

    (@nith)

    Ok, below is a bit more code.

    Basically, I have a ‘slider’ system which uses jQuery. And each <li> item is each ‘slide’ so to speak.

    If you go to nickythorne.com you’ll see what I mean by ‘slider’. I want to list a number of posts on each slide. This is where the scope of my knowledge with WordPress ends ??

    See the commented bit.

    <div id="slider">
    	<ul>
    
    		<?php
    			$taxonomy = 'category';
    			$param_type = 'category__in';
    			$term_args=array(
    				'include'=> '3,4,11',
    				'orderby' => 'name',
    				'order' => 'ASC'
    			);
    			$terms = get_terms($taxonomy,$term_args);
    			if ($terms) {
    				foreach( $terms as $term ) {
    					$args=array(
    						"$param_type" => array($term->term_id),
    						'post_type' => 'post',
    						'post_status' => 'publish',
    						'posts_per_page' => 2,
    						'caller_get_posts'=> 1
    					);
    					$my_query = null;
    					$my_query = new WP_Query($args);
    					if( $my_query->have_posts() ) {
    						echo 'List of Posts in '.$taxonomy .' '.$term->name;
    						while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
    							<li>
    
    								<div class="post-details">
    
    									<!-- It's here where i want the code which will display 5 posts
    										 So as it's a while loop, the <li> element will contain 5 posts in each slide -->
    
    								</div>
    
    							</li>
    
    					    <?php
    						endwhile;
    
    						}
    				}
    			}
    
    			wp_reset_query();?>
    
    	</ul>
    </div>
    Forum: Fixing WordPress
    In reply to: Advanced Query
    Thread Starter Nith

    (@nith)

    Yeah, I want to be able to separate the posts returned into different <li> elements.

    How is this achievable?

    Thanks again.

    Thread Starter Nith

    (@nith)

    Thanks Michael. Appreciate it.

    Thread Starter Nith

    (@nith)

    I want to keep all my posts/data. Just replace the core WordPress files. If i just use the same database details, will WordPress overwrite my existing tables, causing my data to be deleted (which I don’t want)?

    Hope this is clearer.

    Thread Starter Nith

    (@nith)

    But will it overwrite the existing tables?

Viewing 15 replies - 1 through 15 (of 20 total)