This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* modify primary menu so that the anchor links always point back to the homepage | |
*/ | |
if( ! function_exists('nav_items') ) { | |
add_filter( 'wp_get_nav_menu_items','nav_items', 11, 3 ); | |
function nav_items( $items, $menu, $args ) | |
{ | |
if( is_admin() ) | |
return $items; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function 8ii010b_scripts() { | |
// this adds your script to all pages on the site | |
wp_enqueue_script( 'custom-8ii010-js', get_template_directory_uri() . '/js/YOUR-JS-FILE.js', array(), '20151215', true ); | |
// this adds your script to all single posts | |
if ( is_singular('post') ) { | |
wp_enqueue_script( 'custom-8ii010-js', get_template_directory_uri() . '/js/YOUR-JS-FILE.js', array(), '20151215', true ); | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Ran into an issue with a WP site where I needed to change an ACF select dropdown into a real WordPress taxonomy. Wrote this to move the data from an ACF select to taxonomy. This will create terms from an ACF select (manually, have to get the data from the ACF field editing interface). Then it will go through all posts and apply the new taxonomy term according to the ACF select value that already exists on the post. | |
* | |
* ⚠⚠⚠ WARNING ⚠⚠⚠ | |
* | |
* This is not a professional migration thing. If you use this: | |
* Put into `functions.php` or as your own `mu-plugin` file. | |
* Run on a local installation first. If you can run locally and export your DB back to live, even better. | |
* No idea how it'd perform if you had thousands of ACF fields. It worked OK for me with 250 potential ACF select values. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Check if a WordPress page is "current", i.e. it's the current page or the ancestor of a current page | |
* | |
* @uses is_search() | |
* @uses get_post_type() | |
* @uses site_url() | |
* @uses get_permalink() | |
* @uses get_post_type_object() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Get accessible post thumbnail images - fills alt attribute with post title if alt attribute is empty | |
* | |
* @param [type] $id The post ID being called. | |
* @param [type] $size The size of the image to call. Default thumbnail. | |
* | |
* @return void | |
*/ | |
function a11y_images_with_alt( $id, $size = 'thumbnail' ) { | |
$alt = get_post_meta( get_post_thumbnail_id( $id ), '_wp_attachment_image_alt', true ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<h1>H1 heading Medium length headline<h1> | |
<h2>H2 heading Medium length headline</h2> | |
<h3>H3 heading Medium length headline</h3> | |
<h3 class="heading--alternative">H3 heading Medium length headline</h3> | |
<h4>H4 heading Medium length headline</h4> | |
<h5>H5 heading Medium length headline</h5> | |
<h6>H6 heading Medium length headline</h6> | |
<a href="#">Hello i am a link</a> Lorem ipsum dolor sit amet, consectetur adipiscing elit. In consectetur sapien ut sem auctor, id suscipit orci auctor. Nullam nec consequat magna. Aliquam vulputate condimentum sem vitae imperdiet. Duis dignissim ligula quis ligula aliquam, in dapibus sapien auctor. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Redirect single of CPT to page | |
*/ | |
if ( ! function_exists('kw_redirect_resource') ) { | |
add_action( 'template_redirect', 'kw_redirect_resource' ); | |
function shnj_redirect_resource() { | |
if ( is_singular( 'CUSTOM_POST_TYPE_NAME' ) ) : | |
//get the url by path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* | |
* All internal links should open in a new window with rel=noopener | |
* | |
*/ | |
if ( ! function_exists( 'force_external_links' ) ) { | |
add_filter('the_content', 'force_external_links'); | |
add_filter('acf_the_content', 'force_external_links'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@function em($pixels, $context: 16) { | |
@if ( comparable($pixels, 1px)) { | |
@if (unitless($pixels)) { | |
$pixels: $pixels * 1px; | |
} | |
@if (unitless($context)) { | |
$context: $context * 1px; | |
} | |
@return $pixels / $context * 1em; | |
} |
OlderNewer