Skip to content

Instantly share code, notes, and snippets.

@ChrisCree
ChrisCree / functions.php
Last active October 19, 2017 20:26
Force IE not to use so-called "compatibility" mode in the Genesis theme framework.
<?php
// Do not copy opening php tag
// Force Stupid IE to NOT use compatibility mode
add_filter( 'wp_headers', 'wsm_keep_ie_modern' );
function wsm_keep_ie_modern( $headers ) {
if ( isset( $_SERVER['HTTP_USER_AGENT'] ) && ( strpos( $_SERVER['HTTP_USER_AGENT'], 'MSIE' ) !== false ) ) {
$headers['X-UA-Compatible'] = 'IE=edge,chrome=1';
}
return $headers;
@robneu
robneu / check-custom-post-type.php
Last active August 29, 2015 14:00
Check if the current post is a particular post type.
<?php
/**
* Check the current post to see what type of post it is.
*
* This will return true whenever a post is equal to a specified post type.
* It can be useful when making global changes for a particular post type.
*
* @param $post_types array or string the type of posts you're wanting to check.
* @return bool true if the current post type matches any of the checked types.
@calliaweb
calliaweb / modify-tinymce-editor-to-remove-h1.php
Last active August 3, 2023 16:00
Modify TinyMCE editor to remove H1
<?php
// Do NOT include the opening php tag above
add_filter('tiny_mce_before_init', 'tiny_mce_remove_unused_formats' );
/*
* Modify TinyMCE editor to remove H1.
*/
function tiny_mce_remove_unused_formats($init) {
// Add block format elements you want to show in dropdown
$init['block_formats'] = 'Paragraph=p;Heading 2=h2;Heading 3=h3;Heading 4=h4;Heading 5=h5;Heading 6=h6;Address=address;Pre=pre';
@JiveDig
JiveDig / login_form_redirect_errors.php
Last active August 3, 2023 15:59
Login form for template. Redirects back to login page with errors on fail
//* Put these in functions.php
/**
* Description: This redirects the failed login to the custom login page instead of default login page with a modified url
* @link ttp://wordpress.stackexchange.com/questions/110094/custom-login-redirects-to-wp-admin-on-wrong-password
**/
add_action( 'wp_login_failed', 'prefix_front_end_login_fail' );
function prefix_front_end_login_fail( $username ) {
// Getting URL of the login page
<?php
/**
* Get post image.
*/
function wds_get_post_image( $size = 'thumbnail' ) {
// If featured image is present, use that
if ( has_post_thumbnail() ) {
return get_the_post_thumbnail( $size );
@gregrickaby
gregrickaby / change-yoast-seo-metabox-priority.php
Last active September 5, 2024 01:52
Make Yoast SEO your bitch
<?php
/**
* Set Yoast SEO metabox priority to low.
*/
function wds_client_move_yoastseo_metabox() {
return 'low';
}
add_filter( 'wpseo_metabox_prio', 'wds_client_move_yoastseo_metabox' );
@nickcernis
nickcernis / add-editor-layout-classes.js
Last active February 20, 2020 09:09
Add Genesis layout class to Gutenberg editor pages (admin)
// Add genesis layout classes to the Block Editor.
// File lives in the theme's /js/ folder.
wp.domReady(function () {
yourTheme.updateLayoutClass();
var layouts = document.querySelector(".genesis-layout-selector");
if( layouts ) {
layouts.addEventListener("input", function (e) {
yourTheme.updateLayoutClass();