Skip to content

Instantly share code, notes, and snippets.

View jcamp's full-sized avatar

Jonathan jcamp

View GitHub Profile
<?php $item_terms = wp_get_object_terms($post->ID, 'your_taxonomy_name');
if(!empty($item_terms)){
if(!is_wp_error( $item_terms )){
foreach($item_terms as $term){
echo '<h2>'.$term->name.'</h2>';
}
}
}
?>
@jcamp
jcamp / referer.php
Created July 6, 2018 18:19 — forked from barbwiredmedia/referer.php
Checking for page referer in php. Wordpress redirect or header refresh
<?php
//check for refering page to switch content based on referrer
$referrer = $_SERVER['HTTP_REFERER'];
if ($referrer == 'http://url.com' or $referrer == 'http://url-2.com') {
//Matches YES!
} else {
//Matches NO!
header( 'Location: http://www.url.com/no-soup-for-you/' ) ;
@jcamp
jcamp / cf7.txt
Created July 6, 2018 18:19 — forked from barbwiredmedia/cf7.txt
Wordpress Contact form 7 (cf7) fields for headers, additional settings, reply to
MAIL INFORMATION:
To: [email protected]
From: [email protected]
Additional Headers:
Cc: [email protected]
bcc: [email protected]
Reply-to: [your-name] <[your-email]>
@jcamp
jcamp / Contact Form 7: validation.css
Created July 6, 2018 18:00 — forked from barbwiredmedia/Contact Form 7: validation.css
Contact form 7 error styles, validation, cf7 validate
div.wpcf7-response-output, div.wpcf7-validation-errors { display: none !important; }
span.wpcf7-not-valid-tip { display: none; }
input[aria-invalid="true"], select[aria-invalid="true"] { border-color: red; background-color: rgba(153,0,0,0.3) !important; }
span.wpcf7-form-control-wrap {display:block !important;}/*keeps forms from jumping on render*/
@jcamp
jcamp / .htaccess
Created July 6, 2018 18:00 — forked from barbwiredmedia/.htaccess
Increase memory limits. / Increase upload size wordpress , ini
php_value memory_limit 64M
php_value upload_max_filesize 64M
php_value post_max_size 64M
php_value max_execution_time 300
php_value max_input_time 300
@jcamp
jcamp / functions.php
Created July 6, 2018 18:00 — forked from barbwiredmedia/functions.php
Wordpress Get first image in post content if no featured image is available. (blog)
// Get First image for Blog section
function get_first_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = "";
function wpmayor_filter_image_sizes( $sizes) {
unset( $sizes['thumbnail']);
unset( $sizes['medium']);
unset( $sizes['large']);
unset( $sizes['wysija-newsletters-max']);
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'wpmayor_filter_image_sizes');
@jcamp
jcamp / functions.php
Created July 6, 2018 17:59 — forked from barbwiredmedia/functions.php
Wordpress custom admin login screen, logo, and stylesheet
// Create custom login
// redirects to a custom stylsheet
function custom_login_css() {
echo '<link rel="stylesheet" type="text/css" href="'.get_stylesheet_directory_uri().'/assets/css/style-login.css" />';
}
add_action('login_head', 'custom_login_css');
// Change the tool tip
@jcamp
jcamp / template.php
Created July 6, 2018 17:58 — forked from barbwiredmedia/template.php
Wordpress: H1 headlines on different pages.Single / singular / archive
<h1>
<?php if (is_singular('your_cpt') || is_archive('your_cpt') || is_post_type_archive('your_cpt') ) { ?>
YOUR CPT NAME
<?php } elseif (is_search()) { ?>
Search
<?php } elseif (is_404()) { ?>
Error 404
<?php } else { ?>
<?php the_field('headline_text'); ?>
<?php } ?>
@jcamp
jcamp / telephone.css
Created July 6, 2018 17:58 — forked from barbwiredmedia/telephone.css
Telephone attribute selector for click to call coloring on mobile device. Fixes phone number anchor color on phone
a[href^="tel"], a[href^="tel"]:visited, a[href^="tel"]:active, a[href^="tel"]:hover {color:inherit; cursor: text;}
a[href^="tel"]:hover {text-decoration: none;}