I have a multisite with 10 blogs using sitewide tags. Blog 10 is the repository for all posts and is never seen. I don’t want to use the main blog for the repository so I am making custom changes to category.php so that it calls all posts from all blogs matching that cat.
The posts display fine, but the pagination fails (404). I use similar code as below on index.php with switch_to_blog and it pages just fine.
As you will see I am rewriting the links for older and newer posts just as in index.php which switches to blog 10 for many things.
The pagination works fine if I replace the “tags” with “blog” BUT this ends up pointing to blog 10 which I do not want. I am only posting after trying many things and need a separate set of eyes. Thanks in advance.
This is related to your other post: http://wordpress.org/support/topic/plugin-wordpress-mu-sitewide-tags-pages-make-posts-show-under-main-site-cats?replies=7
You’re putting in a lot of effort to replicate what SWT does, and in doing so you’re eradicating the benefit of speed and introducing latency to your site. Switch_to_blog is expensive on your CPU, and yeah, it does weird things with pagination, since you’re using it in a way it’s not intended.
Why can’t you switch Site 10 to be your main site?
I tried that but failed for other reasons. My requirements are:
1. Have blog 1 be aggregate of all blogs (works with both methods)
2. Secondary blogs have three sections that require special queries such as: All (items only posted in blog 1(not agg) AND posts from current), Main (posts only from blog 1(not agg), Blog(posts only from current blog which requires no switching)
If I use the method you mention I have to find a way to filter posts that originate only from blog 1 and not the rest of the posts that are aggregated.
I think either way I am going to have to switch but the less the better.
With that info what do you suggest? And thanks for your input.
That’s a lot of content replication… Why not just redirect people to all (blog10), Main (blog1) and … This blog (blog)? The point of having the separate sites is to keep them separate. If you want all your data to cross over like that, you can just use one site and categories (or CPTs)
I 100% agree with your logic. I wanted to pursue the content in that fashion. I cannot because of the project requirements that are out of my control.
I took this over midstream and am at least trying to make the queries less expensive by not using query_posts and using a filter to change the query before it is run. The original queries were getting tossed away on every page which is painful.
- The topic ‘Pagination issues when using switch_to_blog’ is closed to new replies.