Skip to content

Instantly share code, notes, and snippets.

@infoscigeek
infoscigeek / time_picker_fix.php
Last active October 31, 2016 13:06
Reformatting poorly inputted data and displaying it properly. (In this case, minute and hour fields were stored separately)
<?
//assign variables
$start_hour_field = get_field_object('start_hour');
$starthour = $start_hour_field['value'];
$start_min_field = get_field_object('start_min');
$startmin = $start_min_field['value'];
$end_hour_field = get_field_object('end_hour');
$endhour = $end_hour_field['value'];
$end_min_field = get_field_object('end_min');
@infoscigeek
infoscigeek / orderby-multiple-meta-values.php
Last active October 31, 2016 14:57
How to orderby using multiple custom fields / meta values
<?
//How to orderby using multiple meta values
$query = new WP_Query(
array(
'post_type' => 'sessions',
'posts_per_page' => -1,
'meta_query' => array(
'relation' => 'AND',
'hour_clause' => array(
'key' => 'start_hour',
@infoscigeek
infoscigeek / Logo.html
Created November 7, 2016 13:58
Display logo with a link back to website
<center><a href="http://melissajrubin.com/"><img src="http://melissajrubin.com/wp-content/uploads/2016/09/compass_logo_150x150.png"></a></center>
@infoscigeek
infoscigeek / wordpress.html
Created November 19, 2016 21:13
A few ways to handle line breaks in WordPress
<strong>Miami, We're all Baseling</strong>
As Art Basel 2016 approaches, the event continues to expand to include more innovative shows in new venues. It is important to be strategic so you can cover everything that you would like to. I have highlighted the most visited shows in this email. Get lost, explore and just enjoy your time in Miami during this very creative and fun few days.
Have Fun! Happy Baseling!
<div>
<br class="clear" /><br class="clear" />
<hr />
@infoscigeek
infoscigeek / title-text.php
Created November 21, 2016 13:40
Replacing Placeholder Text in a Custom Post Type
//edit custom field placeholder text in title box
function wpb_change_title_text( $title ){
$screen = get_current_screen();
if ( 'people' == $screen->post_type ) {
$title = 'Enter full name, first and last';
}
return $title;
}
@infoscigeek
infoscigeek / query-by-custom-field.php
Created November 26, 2016 20:58
Query by Custom Field
<?php
// args
$args = array(
'numberposts' => -1,
'post_type' => 'event',
'meta_key' => 'location',
'meta_value' => 'Melbourne'
);
@infoscigeek
infoscigeek / htaccess
Created February 28, 2017 06:51
Redirect all blog posts and pages to a new domain while retaining structure
RewriteEngine on
RewriteCond %{HTTP_HOST} ^oldsite.com [NC,OR]
RewriteCond %{HTTP_HOST} ^www.oldsite.com [NC]
RewriteRule ^(.*)$ http://newsite.com/$1 [L,R=301,NC]
<?php
if (!session_id()) {
session_start();
}
//read variables from the URL
function add_query_vars($aVars) {
$aVars[] = "type"; // represents the name of the affiliate
$aVars[] = "lawyer";
$aVars[] = "city";
return $aVars;
@infoscigeek
infoscigeek / filter-get_the_term_list.php
Created March 18, 2017 05:27
Use a filter to edit the get_the_term_list function
<?php
/* Add nofollow tag to all category and tag links on posts*/
add_filter( "term_links-post_tag", 'add_tag_class');
function add_tag_class($links) {
return str_replace('" rel="tag">', '" rel="tag nofollow">', $links);
}
/* End nofollow tag edit */
?>
@infoscigeek
infoscigeek / custom-schema-header.php
Created March 18, 2017 06:34
Loads Schema from Custom Field on Each Page or Post
<!-- Loads Schema from Custom Field on Each Page or Post -->
<?php
$schema = get_post_meta(get_the_ID(), 'schema', true);
if(!empty($schema)) {
echo $schema;
}
?>
<!-- End Schema Code -->