Forum Replies Created

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

    (@dotsanddashes)

    Erm I had another look into the category ids, and came out with the following:

    function custom_posts_per_page( $query ) {
        if ( is_category( 5 ) or is_category( 110 ) ) {
            // Display 4 posts if the category is live or features
            $query->set( 'posts_per_page', 4 );
            return;
        }
        if ( is_category( 115, 1 ) ) {
            // Display 7 posts if the category is blog
            $query->set( 'posts_per_page', 7 );
            return;
        }
        if ( is_category( 111 ) ) {
            // Display 6 posts if the category is reviews
            $query->set( 'posts_per_page', 6 );
            return;
        }
    }

    The one thing I was wondering – where each tag says ‘if the category is …’ should I try inserting the id as opposed to the name of the category..?

    Thread Starter dotsanddashes

    (@dotsanddashes)

    oh wait – I’m now getting ten features per page, too..?

    Thread Starter dotsanddashes

    (@dotsanddashes)

    that was my fault – didn’t put the code in as it should’ve been and just as the raw, unformatted text…

    So I’ve inserted that new function though it’s all the same as it was before – breaking off at the exact same pages..?

    Should it all snap back to how it should be if I remove those custom queries now..?

    Thread Starter dotsanddashes

    (@dotsanddashes)

    I’m getting an error on (I think it was) line 406 if I put that piece of code in, at which point the site breaks down…

    So were I to put that function in, what would I then need to do to the individual category php files..?

    Thread Starter dotsanddashes

    (@dotsanddashes)

    so to do that, I just separate the numbers with commas, right..?

    The issue is then that certain categories need to show more posts than others…

    So the Reviews need to be on six and not four; the Blog on seven; the Live/ Features on four… I tried to alter the Features bit (id 110) but it’s either stuck on the same broken page (page 8) or it’s showing ten features at a time..?

    Thread Starter dotsanddashes

    (@dotsanddashes)

    Ah OK – my bad! But it’s not the exact same coding that needs to go in for each category, is it..?

    Thread Starter dotsanddashes

    (@dotsanddashes)

    ah you’re right… so before I only had an issue with this particular category, though it now seems to have affected the Blog, Reviews, and the Features… So what do I need to do exactly now..?

    Thread Starter dotsanddashes

    (@dotsanddashes)

    ah amazing – thank you ever so much!

    Thread Starter dotsanddashes

    (@dotsanddashes)

    So at the bottom I’ve got this:

    * Is SubPage?
    *
    * Checks if the current page is a sub-page and returns true or false.
    *
    * @param  $page mixed optional ( post_name or ID ) to check against.
    * @return boolean
    */
    function mv_is_subpage( $page = null )
    {
        global $post;
        // is this even a page?
        if ( ! is_page() )
            return false;
        // does it have a parent?
        if ( ! isset( $post->post_parent ) OR $post->post_parent <= 0 )
            return false;
        // is there something to check against?
        if ( ! isset( $page ) ) {
            // yup this is a sub-page
            return true;
        } else {
            // if $page is an integer then its a simple check
            if ( is_int( $page ) ) {
                // check
                if ( $post->post_parent == $page )
                    return true;
            } else if ( is_string( $page ) ) {
                // get ancestors
                $parent = get_ancestors( $post->ID, 'page' );
                // does it have ancestors?
                if ( empty( $parent ) )
                    return false;
                // get the first ancestor
                $parent = get_post( $parent[0] );
                // compare the post_name
                if ( $parent->post_name == $page )
                    return true;
            }
            return false;
        }
    }
    
    ?>

    Could I just alter that to read:

    * Is SubPage?
    *
    * Checks if the current page is a sub-page and returns true or false.
    *
    * @param  $page mixed optional ( post_name or ID ) to check against.
    * @return boolean
    */
    function mv_is_subpage( $page = null )
    {
        global $post;
        // is this even a page?
        if ( ! is_page() )
            return false;
        // does it have a parent?
        if ( ! isset( $post->post_parent ) OR $post->post_parent <= 0 )
            return false;
        // is there something to check against?
        if ( ! isset( $page ) ) {
            // yup this is a sub-page
            return true;
        } else {
            // if $page is an integer then its a simple check
            if ( is_int( $page ) ) {
                // check
                if ( $post->post_parent == $page )
                    return true;
            } else if ( is_string( $page ) ) {
                // get ancestors
                $parent = get_ancestors( $post->ID, 'page' );
                // does it have ancestors?
                if ( empty( $parent ) )
                    return false;
                // get the first ancestor
                $parent = get_post( $parent[0] );
                // compare the post_name
                if ( $parent->post_name == $page )
                    return true;
            }
            return false;
        }
    }
    
    function custom_posts_per_page( $query ) {
        if ( is_category( 5 ) ) {
            // Display 4 posts if the category is 5
            $query->set( 'posts_per_page', 4 );
            return;
        }
    }
    add_action( 'pre_get_posts', 'custom_posts_per_page', 1 );
    
    ?>
    Thread Starter dotsanddashes

    (@dotsanddashes)

    and can I add that new piece of coding anywhere in the functions.php file..?

    Thread Starter dotsanddashes

    (@dotsanddashes)

    Ah OK – so could it be this one instead..?

    <?php
    /**
     * The template for displaying Live Category Archive pages.
     *
     *
     * @package DotsAndDashes
     *
     */
    
    get_header(); ?>
    
    		<div id="container">
    			<div id="content" role="main">
    
    				<h1 class="page-title">Live</h1>
    				<?php
    					$category_description = category_description();
    					if ( ! empty( $category_description ) )
    						echo '<div class="archive-meta">' . $category_description . '</div>';
    
    				?>
    <?php /* Display navigation to next/previous pages when applicable */ ?>
    
    <?php query_posts(array ( 'cat' => '5', 'posts_per_page' => 4,  'paged' => $paged)); ?>
    <?php if ( ! have_posts() ) : ?>
    	<div id="post-0" class="post error404 not-found">
    		<h1 class="entry-title"><?php _e( 'Not Found', 'dotsanddashes' ); ?></h1>
    		<div class="entry-content">
    			<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'dotsanddashes' ); ?></p>
    			<?php get_search_form(); ?>
    		</div><!-- .entry-content -->
    	</div><!-- #post-0 -->
    <?php endif; ?>
    
    <?php while ( have_posts() ) : the_post(); ?>
    
    		<div id="post-<?php the_ID(); ?>" <?php post_class(array('live-item')); ?>>
    			<div class="thumb-wrapper">
    				<a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title(); ?>"><img src="<?php bloginfo( 'template_url' ); ?>/thumb.php?src=<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID));  ?>&h=300&w=715" alt="<?php echo the_title(); ?>"/></a>
    			<h2 class="entry-title"><a href="<?php the_permalink(); ?>" title="<?php printf( esc_attr__( 'Permalink to %s', 'dotsanddashes' ), the_title_attribute( 'echo=0' ) ); ?>" rel="bookmark"><?php  echo get_post_meta($post->ID, 'Artist', true); ?><br><?php  echo get_post_meta($post->ID, 'Venue', true); ?></a></h2>
    			</div>
    		</div><!-- #post-## -->
    
    <?php endwhile; // End the loop. Whew. ?>
    
    <?php /* Display navigation to next/previous pages when applicable */ ?>
    <?php if (  $wp_query->max_num_pages > 1 ) : ?>
    				<div id="nav-below" class="navigation">
    					<div class="nav-previous"><?php next_posts_link( __( '<span class="meta-nav"></span> <span class="pagi-bracket">[</span>Older<span class="pagi-bracket">]</span>', 'dotsanddashes' ) ); ?></div>
    					<div class="nav-next"><?php previous_posts_link( __( '<span class="pagi-bracket">[</span>Newer<span class="pagi-bracket">]</span> <span class="meta-nav"></span>', 'dotsanddashes' ) ); ?></div>
    				</div><!-- #nav-below -->
    <?php endif; ?>
    
    			</div><!-- #content -->
    		</div><!-- #container -->
    
    <?php get_sidebar(); ?>
    <?php get_footer(); ?>
    Thread Starter dotsanddashes

    (@dotsanddashes)

    OK so I think this is what you’re after, though lemme know if not..?

    Thread Starter dotsanddashes

    (@dotsanddashes)

    ah OK… Thanks anyway – I’ll look into it… I had help on it, as I’m still no whiz when it comes to WordPress..!

    Thread Starter dotsanddashes

    (@dotsanddashes)

    It’s not, no… It’s odd, as whenever a new post in said category is added it just shunts the last one off into nowhere..! So when another now goes up, that Camille piece will no longer show in the section…

    Thread Starter dotsanddashes

    (@dotsanddashes)

    THANK YOU ANDREW!

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