Skip to content

Instantly share code, notes, and snippets.

Avatar

Tim Jensen timothyjensen

View GitHub Profile
View wp_custom_title_placeholder_text.php
<?php
add_filter( 'enter_title_here', function( $title ) {
$screen = get_current_screen();
if ( 'your_custom_post_type' == $screen->post_type ){
$title = 'Your custom placeholder text';
}
return $title;
@timothyjensen
timothyjensen / cpt-registration.php
Last active Jun 4, 2019
Change the placeholder text for the post title field.
View cpt-registration.php
<?php
// Add 'title_placeholder' to the array of arguments when registering the custom post type.
$cpt_args = array(
'title_placeholder' => 'Team member name',
);
register_post_type( 'team_members', $cpt_args );
@timothyjensen
timothyjensen / acf-local-json.php
Last active Jun 4, 2018
Use ACF local JSON file for get_all_custom_field_meta().
View acf-local-json.php
<?php
// Replace with the name of your field group JSON.
$field_group_json = 'group_59e226a200966.json';
$field_group_array = json_decode( file_get_contents( get_stylesheet_directory() . "/acf-json/{$field_group_json}" ), true );
// Omit this line when using the Field Group Values package/plugin.
$config = $field_group_array['fields'];
@timothyjensen
timothyjensen / searchform.php
Created Oct 13, 2017
Modify the standard WordPress search form to perform faceted search.
View searchform.php
<?php
add_filter( 'get_search_form', 'prefix_render_faceted_search_form' );
/**
* Adds checkboxes to the search form for searching specific post types.
*
* @param string $form The search form HTML output.
*
* @return string
*/
function prefix_render_faceted_search_form( $form ) {
@timothyjensen
timothyjensen / jquery.js
Last active Nov 3, 2020
Wrap sibling groups using jQuery.
View jquery.js
$(document).ready(function() {
$(':not(.sibling-element) + .sibling-element, * > .sibling-element:first-of-type').
each(function() {
$(this).
nextUntil(':not(.sibling-element)').
addBack().
wrapAll('<div class="sibling-wrapper" />');
});
});
@timothyjensen
timothyjensen / functions.php
Last active Jun 20, 2017
$wpdb->prepare for SQL IN statements
View functions.php
<?php
$data_types = [ 'data_item_one', 'data_item_two' ];
// Props to @hellofromtonya for this.
$data_type_placeholders = implode( ', ', array_fill( 0, count( $data_types ), '%s' ) );
global $wpdb;
$query = "
SELECT pm.post_id, pm.meta_key, pm.meta_value
@timothyjensen
timothyjensen / functions.php
Last active Jun 4, 2019
Change the default Genesis read more link
View functions.php
<?php
add_filter( 'get_the_content_more_link', 'prefix_change_more_link_text' );
/**
* Replaces the default Genesis [Read More...] with Read More.
*
* @param string $more_link The content more link.
*
* @return string
*/
function prefix_change_more_link_text( $more_link ) {
@timothyjensen
timothyjensen / contact.html
Created Apr 23, 2017 — forked from atcraigwatson/contact.html
Bootstrap Ajax Contact Form
View contact.html
<form id="contact-form" method="post" action="mailer.php" role="form">
<div class="messages"></div>
<div class="controls">
<div class="row">
<div class="col-md-6">
<div class="form-group">
<label for="form_name">Firstname *</label>
@timothyjensen
timothyjensen / functions.php
Created Apr 12, 2017
CMB2 on Genesis Archive Settings.
View functions.php
<?php
add_action( 'cmb2_admin_init', 'yourprefix_register_demo_metabox' );
/**
* Creating a metabox for a Genesis CPT Archive Settings page, where the CPT is 'webinars'.
*/
function yourprefix_register_demo_metabox() {
/**
* Sample metabox to demonstrate each field type included
@timothyjensen
timothyjensen / outside-structural-wrap.php
Last active Mar 24, 2017 — forked from hellofromtonya/before-structural-wrap.php
Insert HTML before or after the Genesis structural wrap for the given contextual area.
View outside-structural-wrap.php
<?php
add_action( 'genesis_meta', 'process_structural_wrap_handler' );
/**
* Process the structural wrap handler.
*
* @since 1.0.0
*
* @return void
*/
function process_structural_wrap_handler() {