This file contains hidden or 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
| add_filter('upload_mimes', 'my_upload_mimes'); | |
| function my_upload_mimes($mimes = array()) { | |
| $mimes['svg'] = 'image/svg+xml'; | |
| return $mimes; | |
| } |
This file contains hidden or 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
| add_action( 'wp_enqueue_scripts', 'enqueue_load_fa' ); | |
| function enqueue_load_fa() { | |
| wp_enqueue_style( 'load-fa', 'https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css' ); | |
| } |
This file contains hidden or 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
| define('WP_MEMORY_LIMIT', '300M'); |
This file contains hidden or 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 wp_tag_cloud(array( | |
| 'smallest' => 10, // size of least used tag | |
| 'largest' => 18, // size of most used tag | |
| 'unit' => 'px', // unit for sizing | |
| 'orderby' => 'name', // alphabetical | |
| 'order' => 'ASC', // starting at A | |
| 'exclude' => 6 // ID of tag to exclude from list | |
| )); | |
| ?> |
This file contains hidden or 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
| if ( function_exists( 'add_image_size' ) ) { | |
| add_image_size( 'my-custom-image1', 400, 9999 ); //400 pixels wide (and unlimited height) | |
| add_image_size( 'my-custom-image2', 320, 250, true ); //(true means the image will be cropped) | |
| } | |
| <?php echo get_the_post_thumbnail($post->ID, 'my-custom-image1'); ?> |
This file contains hidden or 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 redirect_user_on_role() | |
| { | |
| //retrieve current user info | |
| global $current_user; | |
| get_currentuserinfo(); | |
| //If login user role is Subscriber | |
| if ($current_user->user_level == 0) | |
| { | |
| wp_redirect( home_url() ); exit; | |
| } |
This file contains hidden or 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 autoset_featured() { | |
| global $post; | |
| $already_has_thumb = has_post_thumbnail($post->ID); | |
| if (!$already_has_thumb) { | |
| $attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" ); | |
| if ($attached_image) { | |
| foreach ($attached_image as $attachment_id => $attachment) { | |
| set_post_thumbnail($post->ID, $attachment_id); | |
| } | |
| } |
This file contains hidden or 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 | |
| /** | |
| * Set a cookie whenever someone subscribes, storing the form ID | |
| */ | |
| add_action( 'mc4wp_form_subscribed', function( $form ) { | |
| $expires = time() + 3600 * 24 * 90; // 90 days | |
| setcookie( 'mc4wp_subscribed', $form->ID, $expires, '/' ); | |
| }); | |
| /** | |
| * Prints CSS that hides a specific MailChimp for WordPress form if the "subscribed" cookie is set. |
This file contains hidden or 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
| /** | |
| * Remove query string from static resources | |
| */ | |
| function remove_cssjs_ver( $src ) { | |
| if ( strpos( $src, '?ver=' ) ) | |
| $src = remove_query_arg( 'ver', $src ); | |
| return $src; | |
| } | |
| add_filter( 'style_loader_src', 'remove_cssjs_ver', 10, 2 ); |
NewerOlder