Skip to content

Instantly share code, notes, and snippets.

@jpen365
jpen365 / functions.php
Created May 31, 2016 05:06
AJAX Search Form for WP Advanced Search
<?php
/*
* Basic search form for WP Advanced Search
* See http://wpadvancedsearch.com to learn more
*/
require_once('wp-advanced-search/wpas.php');
function demo_ajax_search() {
$args = array();
$args['wp_query'] = array( 'post_type' => array('page', 'post'),
'orderby' => 'title',
@jpen365
jpen365 / ajax-advanced-search.php
Created May 31, 2016 05:10
AJAX WP Advanced Search Template Page
<?php
/*
* This template displays the Ajax Advanced Search Page.
* Template Name: Ajax Advanced Search Page
* See http://wpadvancedsearch.com to learn more
*/
get_header();
$search = new WP_Advanced_Search('myform');
@jpen365
jpen365 / template-ajax-results.php
Created May 31, 2016 05:10
AJAX WP Advanced Search Results Template
<?php
/*
* template-ajax-results.php
* This file should be created in the root of your theme directory
* See http://wpadvancedsearch.com to learn more
*/
if ( have_posts() ) :
while ( have_posts() ) : the_post();
$post_type = get_post_type_object($post->post_type);
@jpen365
jpen365 / simple-table.html
Last active July 7, 2016 05:38
Simple HTML table for responsive table tutorial
<!-- CMS usage data from w3techs.com / captured 7/6/16 -->
<table>
<caption>Most Popular Content Management Systems | July 2016</caption>
<thead>
<tr>
<th>CMS</th>
<th>Usage</th>
<th>Change Since 6/1/16</th>
<th>Market Share</th>
<th>Change Since 6/1/16</th>
@jpen365
jpen365 / responsive-table.js
Last active September 9, 2020 18:57
Get table headings to use with responsive table layout
/* Credits:
This bit of code: Exis | exisweb.net/responsive-tables-in-wordpress
Original idea: Dudley Storey | codepen.io/dudleystorey/pen/Geprd */
var headertext = [];
var headers = document.querySelectorAll("thead");
var tablebody = document.querySelectorAll("tbody");
for (var i = 0; i < headers.length; i++) {
headertext[i]=[];
@jpen365
jpen365 / responsive-table.css
Last active July 12, 2016 11:09
Make HTML tables responsive, requires responsive_tables.js
/* Credits:
This bit of code: Exis | exisweb.net/responsive-tables-in-wordpress
Original idea: Dudley Storey | codepen.io/dudleystorey/pen/Geprd */
@media screen and (max-width: 600px) {
table {width:100%;}
thead {display: none;}
tr:nth-of-type(2n) {background-color: inherit;}
tr td:first-child {background: #f0f0f0; font-weight:bold;font-size:1.3em;}
tbody td {display: block; text-align:center;}
@jpen365
jpen365 / functions.php
Created July 7, 2016 20:02
Enqueue responsive-tables.js with functions.php
<?php
function responsive_tables_enqueue_script() {
wp_enqueue_script( 'responsive-tables', get_stylesheet_directory_uri() . '/responsive-tables.js', $deps = array(), $ver = false, $in_footer = true );
}
add_action( 'wp_enqueue_scripts', 'responsive_tables_enqueue_script' );
<?php
/*
Plugin Name: Custom CSS and JS Plugin
Plugin URI: https://github.com/jpen365/custom-css-and-js-plugin
Description: Add a custom CSS stylesheet and JavaScript file to WordPress
Version: 1.0
Author: Jon Penland
Author URI: http://premium.wpmudev.org/blog/author/jonpenland
*/
@jpen365
jpen365 / enqueue-CSS-and-JS.php
Last active August 25, 2016 22:54
Enqueue a CSS and JS file as part of a plugin.
function custom_css_js_enqueue_scripts() {
/* enqueue the custom-style.css file */
wp_enqueue_style( 'custom-css', plugins_url( '/css/custom-style.css', __FILE__ ), $ver = false );
/* enqueue the custom-scripts.js file */
wp_enqueue_script( 'custom-js', plugins_url( '/js/custom-scripts.js', __FILE__ ), $deps = array( 'jquery' ), $ver = false, $in_footer = true );
}
add_action( 'wp_enqueue_scripts', 'custom_css_js_enqueue_scripts' );
@jpen365
jpen365 / enqueue-theme-assets.php
Last active September 13, 2016 23:20
Enqueue theme CSS and JavaScript resources
<?php
/* enqueue styles and scripts */
function jpen_enqueue_assets() {
/* theme's primary style.css file */
wp_enqueue_style( 'main-css' , get_stylesheet_uri() );
/* template's primary css file */
wp_enqueue_style( 'startup-boostrap-css' , get_template_directory_uri() . './css/blog-post.css' );