Skip to content

Instantly share code, notes, and snippets.

View someguy9's full-sized avatar
🏠
Working from home

Andy Feliciotti someguy9

🏠
Working from home
View GitHub Profile
@someguy9
someguy9 / shortcode-exists.php
Last active July 18, 2023 15:22
Check if a shortcode already exists in WordPress https://smartwp.com/check-if-shortcode-exists/
<?php
if ( shortcode_exists( 'image_gallery' ) ) {
echo 'The [image_gallery] shortcode already exists';
}
if ( !shortcode_exists( 'image_gallery' ) ) {
echo 'The [image_gallery] shortcode does not exist';
}
@someguy9
someguy9 / current-user-id-wordpress.php
Created September 8, 2019 13:45
Display current user ID in WordPress
<?php
echo 'The current logged in user ID is: '.get_current_user_id();
@someguy9
someguy9 / remove-query-strings-from-static-resources.php
Created September 9, 2019 19:34
remove query strings from static content in WordPress
<?php
//Remove Query Strings From Static Resources
function smartwp_remove_query_strings_from_static_resources( $src ) {
if( strpos( $src, '?v=' ) ){
$src = remove_query_arg( 'v', $src );
}
if( strpos( $src, '?ver=' ) ){
$src = remove_query_arg( 'ver', $src );
}
return $src;
@someguy9
someguy9 / wordpress-reverse-comment-order.php
Created January 17, 2020 18:30
Reverse comment order in WorDPress
<?php
//Reverse comment order
function smartwp_reverse_comment_order( $comments ) {
return array_reverse( $comments );
}
add_filter ('comments_array', 'smartwp_reverse_comment_order');
@someguy9
someguy9 / custom-css-wordpress-login.php
Created March 5, 2020 00:14
Add custom CSS to WordPress login page
<?php
//Add custom CSS to WordPress login page
function smartwp_login_page_custom_css() {
?>
<style>
#backtoblog {
display: none !important;
}
</style>
<?php
@someguy9
someguy9 / disable-site-admin-email-verification-screen.php
Created March 12, 2020 13:13
Disable the WordPress site admin email verification screen
<?php
//Disable the WordPress site admin email verification screen
add_filter( 'admin_email_check_interval', '__return_false' );
@someguy9
someguy9 / featured-image-wordpress.php
Created March 15, 2020 21:18
Display a featured image in WordPress
@someguy9
someguy9 / wordpress-featured-image-url.php
Last active December 12, 2020 16:39
Return WordPress post featured image URL
<?php
//Enable theme support for featured images
add_theme_support('post-thumbnails');
@someguy9
someguy9 / get-wordpress-version-number.php
Created March 16, 2020 18:46
Displays the WordPress version number
<?php
//Display the WordPress version number
echo get_bloginfo( 'version' );