Custom headers and footers in WordPress

Today I wanted to put a custom post inside of a fancyBox popup. So, I wanted to have access to WordPress’s functions, but I didn’t want the usual header and footer from my main template… I just wanted a very basic page that would fit easily inside of fancyBox. I didn’t realize it, but WordPress allows you to load custom headers and footers by name using get_header and get_footer.

The naming structure is pretty simple. I copied header.php and renamed it “header-google_map.php.” Then, I stripped it pretty much bare keeping the¬†wp_head(); function call in place so that I would have access to any scripts and styles used by installed plugins. Then, I called my bare-bones header file in a new template file using:

get_header( 'google_map' );

I did the same thing with the footer and this allowed me to have a simple, no-frills page perfect for displaying within a fancyBox. I could use shortcodes within the page and access all my installed plugins.

Simple AppleScript to do lookup in CodeIgniter documentation

Recently, in Coda, I wanted to create a simple way to look up a word directly in the CodeIgniter documentation. While the reference books are nice, there are multiple PHP documentation sources one might want to look up while working. For example, one might want to look up a native PHP function or, if working in Drupal or WordPress, look up something at those particular websites. So, using example code from others, I wrote up a quick AppleScript that allows one to look up the selected word in the CodeIgniter docs (which is really just a Google site search on the codeigniter.com domain). Without further ado, here it is:


tell application "Coda 2"
try
tell selected split of selected tab of front window
if selected text is not equal to "" then
set someText to selected text
end if
set myQuery to do shell script "php -r 'echo trim(urlencode(" & "\"" & someText & "" & "\"));'"
end tell
end try
end tell
tell application "System Events"
try
if myQuery is not equal to "" then
open location "https://www.google.com/search?as_sitesearch=codeigniter.com%2Fuser_guide%2F&q=" & myQuery & "&sa=Go"
end if
on error
beep
end try
end tell

Very simple stuff! Basically, it looks in the active split and grabs the selected text if any is available. From there it uses PHP to encode the text for a URL (to deal with any problem special characters) and then, if there is resulting text, opens the location:

https://www.google.com/search?as_sitesearch=codeigniter.com%2Fuser_guide%2F&q=[selected_text]

Again, nothing special. I have no doubt that some nice bells and whistles could be added to this script. One thing that isn’t immediately obvious to me is how to select a word that the cursor is in using AppleScript.

AppleScripts in the Coda AppleScript menu can be put into folders so I can have a Documentation folder and then have as many sources as I need nested in a logical way.