Category Page which plays well with paginated post archive and SEO

Not sure if this what category this question belongs, but I am at a critical crossroads and need direction.

I have a local online news site.

http://rheareview.com

It's been live for about 6 months, and I have thus far used my theme's built-in "category by archive" feature to display posts in a particular category. (Just now learning the best way to build a proper seo sitemap and make use of seo funtionality for news publishers.)

Now that my site has begun to grow. I am running into some growing pains. I am implementing a section dedicated to "Outdoors".

http://rheareview.com/outdoors

Now here's where I need guidance. My "Lifestyles" category is the parent of the "Outdoors" section. With my permalink structure, that automatically creates the post archive at "http://rheareview.com/lifestyle/outdoors"

So what I have is a page which has a custom layout for my new "Outdoors" section. Now I have a solution for providing a fluid transition to archives in placing a link to "http://rheareview.com/lifestyle/outdoors/page/2"
What is the best way to force wordpress and seo sitemap to display this section correctly. Can I make a change to the database or is there a plugin that will help? I want the sitemap to show "Outdoors" when people go to the outdoors section I want them to see the 10 posts in a custom layout as seen on page, but I want them to be able to go to older posts at bottom. The main concern is that I want my site indexed properly in the sitemap while retaining as much built-in wordpress post-indexing features as possible.

Whatever method I choose will be used in other sections of my site as well. I also need the solution to be permanent in that I can't have changes wiped out during a future update to my theme or wordpress itself.

What I want to do is when the category "Outdoors" is shown in the post teaser in the post. The link does not go to "http://rheareview.com/lifestyle/outdoors" but goes to the custom section "http://rheareview.com/outdoors"

Thanks in advance to everyone who has taken the time to help.

Elmer

  • Ash

    Hello @elmer_harris

    Welcome to WPMU community!

    I hope you are well today and thanks for asking the question.

    This is an interesting question. I have never tried this before. Would you please try the following code in your functions.php:

    add_action( 'init', 'build_taxonomies', 0 );  
    
    function build_taxonomies() {
    
      register_taxonomy( 'category', 'post', array(
    		'hierarchical' => true,
    	 	'update_count_callback' => '_update_post_term_count',
    		'query_var' => 'category_name',
    		'rewrite' => did_action( 'init' ) ? array(
    					'hierarchical' => false,
    					'slug' => get_option('category_base') ? get_option('category_base') : 'category',
    					'with_front' => false) : false,
    		'public' => true,
    		'show_ui' => true,
    		'_builtin' => true,
    	) );
    
    }

    Please keep a backup of your site before doing so.

    Let me know if that works.

    Cheers
    Ash

  • elmer_harris

    Ash,

    That works amazingly. I can't believe it worked without bugs right off the rip.

    The only problem I have now is that I don't have a link to archived posts. What can we come up with to

    See that custom page is set to have 10 posts (the default # of posts per archive page). So at the bottom of that page I was going to add a link to "Older Outdoor Articles" which would go to:

    http://rheareview.com/lifestyle/outdoors/page/2

    That archive page is no longer there after the modification we made. I'm cool with that as I love and desperately needed that modification. Can you please help me find a workaround which will either show posts in that category with an offset of 10?

    thanks so much. The mod was unbelievable. Your a genious and I'm not patronizing. I am sincerely grateful.

    Elmer

  • elmer_harris

    Ash,

    The page is a standard page with shortcodes that pulling in the posts. The top two posts (in large grid-style) are pulled with one shortcode:

    [row]

    [insert_posts cats="73" num="2" display_style="two-col" excerpt_length="90"]

    [/row]

    and the list-style posts use the following shortcode:

    [row]

    [insert_posts cats="73" num="8" display_style="list-big" excerpt_length="210" offset="2"]

    [/row]

    So that is how I am limiting the posts to 10 on that page.

    thanks,

    Elmer

  • Ash

    I don't think you can add pagination when you are pulling posts by shortcode. Anyway, try the following code, it looks some mess but somehow it worked for me :slight_smile:

    add_action('the_content', 'category_page');
    function category_page($content) {
    	global $post, $page;
    	$curpage = 'http://localhost/forum/scode/';
    	if($post->ID == 301) {
    		echo $pageno = get_query_var('paged');
    		if((int)$pageno > 1)
    			return do_shortcode('
    				[row]
    
    				[insert_posts cats="73" num="2" display_style="two-col" excerpt_length="90" offset="'.(($pageno-1)*10).'"]
    
    				[/row]
    
    				and the list-style posts use the following shortcode:
    
    				[row]
    
    				[insert_posts cats="73" num="8" display_style="list-big" excerpt_length="210" offset="'.((($pageno-1)*10)+2).'"]
    
    				[/row]
    				').'
    				<br>
    				<a style="float: left" href="'.$curpage.'page/'.($pageno-1).'">Newer Posts</a>
    				<a style="float: right" href="'.$curpage.'page/'.($pageno+1).'">older Posts</a>
    				';
    		else
    			return do_shortcode('
    				[row]
    
    				[insert_posts cats="73" num="2" display_style="two-col" excerpt_length="90"]
    
    				[/row]
    
    				and the list-style posts use the following shortcode:
    
    				[row]
    
    				[insert_posts cats="73" num="8" display_style="list-big" excerpt_length="210" offset="2"]
    
    				[/row]
    				').'
    				<br>
    				<a style="float: right" href="'.$curpage.'page/'.($pageno+2).'">older Posts</a>
    				';
    	}
    }

    You need to change two things in the above code. One is $curpage, that should be in your case http://rheareview.com/lifestyle/outdoors/ or http://rheareview.com/outdoors/ and $post->ID == 301; you need to change this 301 with the original page ID.

    You can add those codes in your functions.php in the theme, if you think your theme won’t be changed. Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'. If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that, give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins, so it will be activated automatically always.

    Please let me know if you find this is helpful, or if you have any further questions.

    Cheers
    Ash

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.