Skip to content

Instantly share code, notes, and snippets.

View kellenmace's full-sized avatar

Kellen Mace kellenmace

View GitHub Profile
/*
* Enqueue jQuery when adding/editing a Project Summary
*/
function rpt_enqueue_jquery_for_custom_post_type( $hook ){
global $post;
// if the current post is not a "project_summary" post type, exit this function
if ( 'project_summary' != $post->post_type ) {
return;
}
/*
* Require post title when adding/editing a Project Summary
*/
function rpt_require_post_title_for_custom_post_type() {
global $post;
// only run the code below if this is a "project_summary" post type
if ( 'project_summary' == $post->post_type ) {
?>
<script type='text/javascript'>
// The list of post types that we want to require post titles for
$post_types = array( 'post', 'page', 'event', 'project' );
// If the current post is not one of the chosen post types, exit this function
if ( in_array( $post->post_type, $post_types ) ) {
return;
}
/*
* Require post title when adding/editing a Project Summary
*/
function rpt_require_post_title_for_custom_post_type() {
global $post;
// only run the code below if this is a "project_summary" post type
if ( 'project_summary' == $post->post_type ) {
?>
<script type='text/javascript'>
<form id="service-category-select" class="service-category-select" action="<?php echo esc_url( home_url( '/service-category/' ) ); ?>" method="get">
<?php wp_dropdown_categories( array(
'orderby' => 'NAME',
'taxonomy' => 'service_category',
) ); ?>
<input type="submit" name="submit" value="view" />
</form>
<form id="service-category-select" class="service-category-select" action="<?php echo esc_url( home_url( '/' ) ); ?>" method="get">
<?php wp_dropdown_categories( array(
'orderby' => 'NAME',
'taxonomy' => 'service_category',
'value_field' => 'term_id'
) ); ?>
<input type="submit" name="submit" value="view" />
</form>
@kellenmace
kellenmace / custom-taxonomy-dropdown.php
Created June 25, 2015 13:05
Create a custom taxonomy dropdown in WordPress
<div class="all-tools">
<?php
// If the taxonomy term has previously been selected from the dropdowm menu, grab it
$term = isset( $_GET[ 'tools' ] ) ? sanitize_text_field( $_GET[ 'tools' ] ) : false;
// In this section, set selected and taxonomy_query values before creating the taxonomy dropdown & getting WP_Query results
$selected = '';
$tax_query = '';
if ( $term ) {
<?php
/*
Plugin Name: Add Facebook Conversion Pixel with Custom Post Widget
Description: Add Facebook Conversion Pixel with Custom Post Widget
Version: 1.0
Author: Kellen Mace
Author URI: http://kellenmace.com/
License: GPLv2 or later
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
wp_enqueue_script( 'admin_scripts', DABO_URL . 'assets/js/tenup_dashboard_admin.js', array( 'jquery' ), DABO_VERSION );
wp_enqueue_style( 'admin_styles', DABO_URL . 'assets/css/tenup_dashboard_admin.css', array(), DABO_VERSION);