Forum Replies Created

Viewing 15 replies - 16 through 30 (of 97 total)
  • Thread Starter paa1605

    (@paa1605)

    Just realised that i should have been using the <?php posts_nav_link(); ?> rather than the next_post_link given that this is a category page. Unfortunately though the problem still persists. It’s still creating a page 2 showing the same 2 posts.

    Thread Starter paa1605

    (@paa1605)

    Thanks Josh,

    I’ve put your code in and it works!! However, there seems to be a slight problem.

    I removed the argument line that states ’10 posts per page’ as my wordpress settings has it currently showing just 3 which is fine as i’m building the site on my testing server. There are only 2 posts which meet the arguments criteria (ie. in the current category and not in 46), and although these are now the only ones that are showing, the next_post_link is displaying and linking to a page 2 which again shows the same 2 posts!?

    This is strange as there shouldn’t be a page 2 because there are only 2 posts meeting the argument and the settings are set to 3 posts per page. Do you know why it would duplicate the same posts and put them on a second page?

    Thanks. The full code is as follows…

    <?php
    $args=array(
      'category__in' => $ps_catid,  // Taken from your example above
      'category__not_in' => '46'  // Taken from your example above
    );
    $my_query = null;
    $my_query = new WP_Query($args);
    if( $my_query->have_posts() ) {
      while ($my_query->have_posts()) : $my_query->the_post(); ?>
    
                                    <div class="trends_panel">
    
                                                <div class="trends_header">
    
                                                        <div class="trends_date">
                                                        	<?php the_time('F jS, Y') ?>
                                                        </div>
    
                                                                    <div class="trends_title">
    
                                                                        <h1><a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?>
                                               								</a>
                                                                        </h1>
    
                                                                    </div>
    
                                                                    			<?php $image = get_post_meta($post->ID, 'category image', true);
    
    																		   if($image) : ?>
    
    																		   <a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
                                                                               	<img src="<?php echo $image; ?>" border="0" class="resize" />
    																		   </a>
    
    																		   <?php endif; ?>
    
                                                                                        <div class="trends_excerpt">
                                                                                            <?php the_excerpt(); ?>
                                                                                        </div>
    
                                                                                                <div class="trends_more">
                                                                                                <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>">Read More
                                                                                                </a>
                                                                                                </div>
                                                </div>
    
                                    </div>
    
                    																	<?php
      endwhile;
    }
    wp_reset_query();  // Restore global post data stomped by the_post().
    ?>
    
                                                                                     <div class="clear">
                       															     </div>   			
    
                                <?php previous_posts_link('&laquo; More Recent Posts') ?>
    
                                    <?php next_posts_link('Older Posts &raquo;') ?>
    Thread Starter paa1605

    (@paa1605)

    Thanks for the help guys.

    After taking what you said onboard it turns out it was indeed a problem with the ‘disable date-based archives’ in the seo plug-in. All fixed now and working perfectly. Thanks!

    Thread Starter paa1605

    (@paa1605)

    Thanks Shane, seems to be working perfectly now!

    Many thanks

    Thread Starter paa1605

    (@paa1605)

    No plugin, just the code i’ve mentioned in the original post. The theme is one that i made myself.

    This works perfectly for what you’re trying to achieve…

    https://www.ads-software.com/extend/plugins/intuitive-category-checklist/screenshots/

    Thread Starter paa1605

    (@paa1605)

    Thankyou both for your help. Got it to work perfectly!

    Thread Starter paa1605

    (@paa1605)

    Thanks everyone for all the help. I managed to get both problems sorted so many thanks!

    Patrick

    Thread Starter paa1605

    (@paa1605)

    Thanks Andrew, that works perfectly!!

    Any ideas about making the query category specific?

    And if the h2 has a class applied to it how is that written?

    Thanks for your time, much appreciated.

    Thread Starter paa1605

    (@paa1605)

    Oh sorry, the last two lines.

    Thread Starter paa1605

    (@paa1605)

    For anyone thats interested, i think i’ve cracked it…

    <?php
    $original_id = get_post_meta($post->ID, 'price', true);
    $sale_id = get_post_meta($post->ID, 'sale price', true);
    if ($sale_id != $original_id) { ?>
    <div>Was &pound;<?php echo get_post_meta($post->ID, 'price', true); ?></div>
     <div class="salebox">Now &pound;<?php echo get_post_meta($post->ID, 'sale price', true); ?></div>
    
    <?php } else { ?>
     &pound;<?php echo get_post_meta($post->ID, 'price', true); ?>
    <?php } ?>

    Thread Starter paa1605

    (@paa1605)

    Brilliant, many thanks. That seems to work.

    Could i just ask how do i echo the ‘£’ symbol before the new price and also add a ‘was’ and ‘now’. So for example it would say..

    Was £10 Now £8

    Thread Starter paa1605

    (@paa1605)

    Thanks vtxyzzy, worked perfectly!!!

    All the best!

    Thread Starter paa1605

    (@paa1605)

    this is the code i have in my functions file

    // Register the column
    function revised_column_register( $columns ) {
        $columns['revised'] = 'Revised';
        return $columns;
    }
    
    add_filter( 'manage_edit-post_columns', 'revised_column_register' );
    
    // Display the column content
    function revised_column_display( $column_name, $id ) {
        if ('revised' == $column_name)
            echo get_post_field('post_modified', $id);
    }
    add_action( 'manage_posts_custom_column', 'revised_column_display', 10, 2 );
    
    // Register the column as sortable
    function revised_column_register_sortable( $columns ) {
    	$columns['revised'] = 'modified';
    
    	return $columns;
    }
    add_filter( 'manage_edit-post_sortable_columns', 'revised_column_register_sortable' );
    
    function revised_column_orderby( $vars ) {
    	if ( isset( $vars['orderby'] ) && 'revised' == $vars['orderby'] ) {
    		$vars = array_merge( $vars, array(
    			'orderby' => 'revised'
    		) );
    	}
    
    	return $vars;
    }
    add_filter( 'request', 'revised_column_orderby' );

    I got it from an article i found here

    Custom Sortable columns

    I can’t seem to see where the code is that controls the date format though. Thanks for taking the time to reply, much appreciated.

    Thread Starter paa1605

    (@paa1605)

    Fantastic WillxD!!! That works perfectly. A massive thanks.

    Can i just ask something else. If i have a post assigned to several categories such as ‘golf’, ‘nike’, ‘new this week’ and ‘new this month’ is it possible to add something to the code you provided so that it automatically removes itself from the category of ‘new this week’ after 7 days, and also removes itself from the category of ‘new this month’ after 30 days??

    If you could get the code to do this it would be a perfect solution to my problem.

    Thanks again for all your kind work so far. Very much appreciated.

    Regards,
    Patrick

Viewing 15 replies - 16 through 30 (of 97 total)