<?php add_action( ‘template_redirect’, ‘template_redirect_example’ ); function template_redirect_example() { if ( is_search() ) { global $wp_query; if ( 1 == $wp_query->post_count && 1 == $wp_query->max_num_pages ) { wp_redirect( get_permalink( $wp_query->posts[‘0’]->ID ) ); exit; } } } // Example Source: http://www.elegantthemes.com/blog/tips-tricks/eight-useful-code-snippets-for-wordpress
Development
WordPress Rewrite API – add_rewrite_rule to trigger an action
It’s easy to create URLs with WP that find and map to content. Making URLs that trigger an action is a bit harder. The main idea here is that I want a specific action to take place when a user clicks a link to a specific URL. Let’s say unsubscribe from a mailing list. The […]
OS X Bulk Rename Files Using Regex
brew install rename rename -v -n ‘s/NewssRadios[(d).(d{2,2})]s(.*).avi/News.Radio.S0$1E$2.$3.avi/’ *.avi -v = verbose -n = dry-run
Stupid Developer Tricks
¿uʍop ǝpısdn ǝdʎʇ oʇ ǝ|qɐ ǝq oʇ ʇuɐʍ noʎ os #!/usr/bin/perl use strict; use warnings; use utf8; binmode(STDOUT, “:utf8”); my %flipTable = ( “a” => “x{0250}”, “b” => “q”, “c” => “x{0254}”, “d” => “p”, “e” => “x{01DD}”, “f” => “x{025F}”, “g” => “x{0183}”, “h” => “x{0265}”, “i” => “x{0131}”, “j” => “x{027E}”, “k” => […]
Git – list of conflicted files
git diff –name-only –diff-filter=U from SO
Git SVN not working after Yosemite upgrade
→ git svn clone -r HEAD https://vip-svn.wordpress.com/yrc-freight Can’t locate SVN/Core.pm in @INC (you may need to install the SVN::Core module) (@INC contains: /usr/local/Cellar/git/1.8.5.2/lib/perl5/site_perl /Library/Developer/CommandLineTools/Library/Perl/5.16/darwin-thread-multi-2level /Library/Perl/5.18/darwin-thread-multi-2level /Library/Perl/5.18 /Network/Library/Perl/5.18/darwin-thread-multi-2level /Network/Library/Perl/5.18 /Library/Perl/Updates/5.18.2 /System/Library/Perl/5.18/darwin-thread-multi-2level /System/Library/Perl/5.18 /System/Library/Perl/Extras/5.18/darwin-thread-multi-2level /System/Library/Perl/Extras/5.18 .) at /usr/local/Cellar/git/1.8.5.2/lib/perl5/site_perl/Git/SVN/Utils.pm line 6. BEGIN failed–compilation aborted at /usr/local/Cellar/git/1.8.5.2/lib/perl5/site_perl/Git/SVN/Utils.pm line 6. Compilation failed in require at /usr/local/Cellar/git/1.8.5.2/lib/perl5/site_perl/Git/SVN.pm line 26. BEGIN failed–compilation […]