Skip to content

Instantly share code, notes, and snippets.

@benwo
benwo / wp-cpt.php
Last active January 20, 2016 00:23
Wordpress - Custom Post Type template
<?php
// Example basic template for setting up a post type called 'Project'
function cpt_project() {
$labels = array(
'name' => _x( 'Projects', 'post type general name' ),
'singular_name' => _x( 'Project', 'post type singular name' ),
'add_new' => _x( 'Add New', 'project' ),
'add_new_item' => __( 'Add New Project' ),
@benwo
benwo / wp-functions-cpt-ui-title-placeholder.php
Created January 12, 2015 00:54
Wordpress: Post Type UI Title Placeholder Fix
<?php
// Fix post type placeholder title
function wpb_change_title_text( $title ){
$screen = get_current_screen();
if ( 'broker' == $screen->post_type ) {
$title = "Enter the broker's full name";
}
@benwo
benwo / fluid-video.js
Created January 9, 2015 00:30
Fluid Video Embeds
<script>
// Find all videos
var $allVideos = $("iframe[src^='http://player.vimeo.com'], iframe[src^='http://www.youtube.com'], iframe[src^='https://www.youtube.com']"),
// The element that is fluid width, aka the parent element of the video
$fluidEl = $("#content-platter");
// Figure out and save aspect ratio for each video
$allVideos.each(function() {
@benwo
benwo / bs-navbar-collapse-togle.js
Last active August 29, 2015 14:10
Collapse bootstrap navbar after an item is clicked in the dropdown (for mobile widths).
$(document).on('click','.navbar-collapse.in',function(e) {
// If child is an anchor or has class dropdown-toggle
if( $(e.target).is('a') || ( $(e.target).attr('class') != 'dropdown-toggle' ) ) {
// Collapse the dropdown nav
$(this).collapse('hide');
}
});
@benwo
benwo / meta-tags.html
Last active May 13, 2024 21:44
Standard meta tags and meta image tags (and sizes).
<!DOCTYPE html>
<html itemscope itemtype="http://schema.org/Organization" lang="en">
<head>
<!-- Settings -->
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<!-- Search Engines -->