Skip to content

Instantly share code, notes, and snippets.

@atsea
atsea / gist:7a216554e64a573600b5
Created October 7, 2014 14:46
Enahnce 404 Error Page
<div class="entry">
<!--If no results are found-->
<h1><?php esc_html_e('Oops!','Nimble'); ?></h1>
<h3 style="margin-bottom:3em">The page you requested, <em style="color:#00539f">'<?php echo "http://" . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'] ; ?>'</em> could not be found. </h3>
<p>Choose a search option below or use the navigation above to locate your software.</p>
<?php get_search_form();
/**
* Enhance 404 Error Page
* http://codemug.com/php/enhance-404-error-page-make-it-powerful/
@atsea
atsea / build_select.php
Created November 10, 2014 14:55
Build select lists for search form
/**
* How to create an advanced search form for wordpress
* http://fearlessflyer.com/how-to-create-an-advanced-search-form-for-wordpress/
*/
function buildSelect($tax){
$terms = get_terms($tax);
//$tax = preg_replace('/^software_/', '', $tax);
//$tax_name = str_replace('_', ' ', $tax_name);
$prefix = 'software_';
$tax_name = preg_replace('/^' . preg_quote($prefix, '/') . '/', '', $tax); //preg_replace('/^software_/', '', $tax);
@atsea
atsea / add_custom_columns.php
Created November 12, 2014 13:43
Wordpress Add Custom Columns
/**
* Add a Custom Column in Posts and Custom Post Types Admin Screen
* http://code.tutsplus.com/articles/add-a-custom-column-in-posts-and-custom-post-types-admin-screen--wp-24934
*/
/**
* Custom Post Type Snippets to make you smile
@atsea
atsea / gist:15323a72f3f4891018e0
Created December 3, 2014 15:33
SQL: Replace strings in multiple records
UPDATE some_table SET some_field = REPLACE(columnName, 'test', 'sample')
@atsea
atsea / gist:e5d993348b69181a7070
Created December 3, 2014 15:36
SQL: Delete column from table
ALTER TABLE table_name DROP column_name
@atsea
atsea / if url contains.php
Created February 25, 2015 18:19
php: if url contains
/*
* If Url contains
* https://www.drupal.org/node/1214104
*/
$path = $_SERVER['REQUEST_URI'];
$find = 'design';
$pos = strpos(SERVICES_CONTAIN, $find);
if ($pos !== FALSE){
echo "current page: " . $find;
}
@atsea
atsea / sprintf.php
Created March 4, 2015 18:07
php - sprintf example
$string = <<<EOHTML
<section id="anniversary_mobile" class="row">
<div class="four columns">
<figure>
<img class="head hires" src="%s15-years-15mobile.png" width="246" height="185" alt="Celebrating 15 years of blowing customers minds">
</figure>
</div>
</section>
EOHTML;
@atsea
atsea / localize.php
Created April 15, 2015 19:13
WordPress: add php to js with wp_localize_script
/**
* Move JS to Bottom of Footer
* http://www.wpbeginner.com/wp-tutorials/how-to-move-javascripts-to-the-bottom-or-footer-in-wordpress/
*/
/*
* Use wp_localize_script to load php into js
* https://pippinsplugins.com/use-wp_localize_script-it-is-awesome/
*/
@atsea
atsea / sidebar.php
Created April 22, 2015 19:24
wordpress - display thubmnail in sidebar recent posts
<?php
/**
* http://officetricks.com/display-recent-posts-with-thumbnails-without-plugins/
* Display Recent Posts with Thumbnails without Plugins – WordPress
*/
$recent_posts = wp_get_recent_posts();
foreach( $recent_posts as $recent ){
if($recent['post_status']=="publish"){
if ( has_post_thumbnail($recent["ID"])) {
echo '<li style="padding:5px;border-bottom:1px solid goldenrod;">
@atsea
atsea / submenu-descrption.php
Created May 6, 2015 14:20
WordPress: add description to submenu
<?php
/**
* start_lvl and end_lvl
* How can I add parent menu description to my Wordpress menu?
* http://stackoverflow.com/questions/29251897/how-can-i-add-parent-menu-description-to-my-wordpress-menu
*
* start_el
* * How to add menu descriptions to wordpress theme
* http://www.wpbeginner.com/wp-themes/how-to-add-menu-descriptions-in-your-wordpress-themes/
*/