| View previous topic :: View next topic |
| Author |
Message |
Garrett Williams

Joined: 11 Apr 2008 Posts: 31 Location: Missouri
|
Posted: Tue Apr 22, 2008 11:22 am Post subject: Archive: redirect if only one result? Integrating 2 sites. |
|
|
If there's only one search result in the archive, specifically if I go to a specific day(site.com/2008/04/22/), is there a way to get Wordpress to just go directly to that comic's page, instead of requiring another click?
This is just one solution I'm pondering. What I'm doing is offering English and Spanish versions of my comic, and providing a direct link between comics. Trouble is, the slug(last part of url) will be different, because I want the slug to be in the same language as the comic. This makes it difficult to get the page to guess the full address of its sibling. I could just have the slug be "comic", but that makes it easy for people to guess the url of upcoming comics. I currently have the "en espaņol" link pointing to the day of the comic, which puts up a half-sized comic and none of the extra features that show up on the actual comic page.
Other options I'm considering:
-Having the archive show up full-width and trying to make each entry as full as possible. (still too limited)
-Installing a language plug-in and making deep changes to Comicpress to have each language template use different code to display the appropriate comic.
-Find SOME way to make the page either guess the page slug or grab it from the site. Maybe use the number of characters in the comic as the slug, something that'll be relevant to both versions and hard to guess beforehand.(probably the best route) ...alternatively I could use the same English slug and hope Google Adsense will still deliver ads in Spanish, and hope I remember the English slug(I've been posting the Spanish version weeks after, but still within the buffer).
Both languages currently have their own installation, and I believe this is the best way to have the Spanish site be 100% in Spanish. |
|
| Back to top |
|
 |
Garrett Williams

Joined: 11 Apr 2008 Posts: 31 Location: Missouri
|
Posted: Wed Apr 23, 2008 10:18 pm Post subject: |
|
|
| Hmm, actually, I think setting the permalink to be the year/month without the day, and slugging it with the day would work well. I just found out that, at least in WP 2.5, that you have to be logged in to see future posts(even when given a direct link). Too bad I found out because I sent someone a direct link to a future comic. |
|
| Back to top |
|
 |
karchesky

Joined: 10 Feb 2008 Posts: 276
|
Posted: Thu Nov 13, 2008 9:56 am Post subject: |
|
|
Well, this might come a little late for your particular case. Even so, I've set this up on my site and it works rather well. What I wanted was having people click on a certain day on the calendar and be shown the comic for that day rather than an archive page showing that there was indeed a single entry for that day which they then had to click on to get to the actual comic.
In other words I wanted: click on calendar day = see that day's comic.
The solution is rather simple. Just paste this code at the top of archive.php:
| Code: | <?php if (have_posts()) :
$postcount = 0;
while (have_posts()) : the_post();
$postcount += 1;
endwhile;
if (is_day() && $postcount == 1) wp_redirect(get_permalink());
endif; ?> |
What this does is count the number of items there are to show and, if it's a daily archive (which is what you get by clicking on a calendar day), and there is only one entry that day, the you are redirected to that entry. Since most comics only have one entry per day at most, this works just fine. And if there are more than one entry in any given day then it behaves as usual, showing you the archives for that day.
You can see this at work in my site. Cheers, _________________
 |
|
| Back to top |
|
 |
Garrett Williams

Joined: 11 Apr 2008 Posts: 31 Location: Missouri
|
Posted: Thu Nov 13, 2008 9:59 pm Post subject: |
|
|
Thanks! Works perfectly and is extremely easy to implement! I even tested to make sure it doesn't mess with multi-post archives.
As for multi-post days, in the redesign I'm working on, I plan on comics showing full-size with the blog entry. Even with that, though, one-post days would react much better with this fix, so I'll be carrying this over. _________________
 |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|