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 | |
// This code snippet uses the first paragraph of an article as excerpt | |
// use an anonymous function to filter the excerpt | |
// this changes the behavior of the function the_excerpt() to use the first paragraph | |
add_filter( 'wp_trim_excerpt', function( $text, $raw_excerpt ) { | |
$content = apply_filters( 'the_content', get_the_content() ); | |
return substr( $content, 0, strpos( $content, '</p>' ) + 4 ); | |
} ), 10, 2 ); | |
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
define('DISABLE_WP_CRON', '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
@media screen and (min-width: 56.875em) { | |
.site-main { | |
-moz-column-count: 2; | |
-webkit-column-count: 2; | |
column-count: 2; | |
} | |
.site-main h1 { | |
-moz-column-span: all; | |
-webkit-column-span: all; | |
column-span: all; |
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 | |
// This code snippet adds additional file types allowed to upload | |
// Add a custom function to add needed mime types | |
add_filter( 'upload_mimes', 'add_mime_types' ); | |
function add_mime_types( $mime_types ) { | |
// add file extensions .svg, .webp, .ai, .eps, .ep, .xml | |
// more file extensions can be added just the same |
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 | |
// This code snippet disables the URL autocorrection guessing feature of WordPress | |
// Add a custom function to disable autocorrection guessing | |
add_filter( 'redirect_canonical', 'stop_url_autocorrect' ); | |
function stop_url_autocorrect( $redirect_url ) { | |
if ( is_404() && !isset( $_GET['p'] ) ) { | |
$redirect_url = false; | |
} |
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 | |
// This code snippet removes the "Screen Options" Tab from the top right corner of the WordPress Admin | |
add_filter( 'screen_options_show_screen', '__return_false' ); | |
?> |
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 | |
// This code snippet blocks WordPress dashboard access for non admin users | |
// Add a custom function to check if the user is allowed to access the admin area | |
add_action( 'init', 'block_admin_access' ); | |
function block_admin_access() { | |
if ( is_admin() && ! current_user_can( 'administrator' ) && ! ( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) { | |
// Redirect to home page if a non admin user tries to access admin area | |
wp_redirect( home_url() ); |
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 | |
// This code snippet stops WordPress from redirecting a variety of URLs to the admin area | |
remove_action( 'template_redirect', 'wp_redirect_admin_locations', 1000 ); | |
?> |
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 | |
// This code snippet prevents WordPress from giving hints on incorrect logins | |
// Add a custom function to filter the login error message | |
add_filter( 'login_errors', 'hide_login_hint' ); | |
function hide_login_hint( $error ){ | |
// No matter what error occurred always display the same message | |
return 'Login incorrect.'; | |
} |
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 | |
// This code snippet hides exclusive content if the user is not logged in | |
// To hide content you have to create a category with the slug 'only-for-members' | |
// All posts assigned to this category will be hidden from not logged in users | |
// Add a custom function to filter the content | |
add_filter( 'the_content', 'exclusive_content', 99 ); | |
// If the user is not logged in, the excerpt will be displayed plus a message that the content is avialable only for registered users |
NewerOlder