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 | |
// Get the current post or page's slug | |
$slug = get_post_field( 'post_name', get_post() ); | |
echo $slug; | |
// Get slug for a post or page by ID | |
$post_id = 1; | |
echo get_post_field( 'post_name', $post_id ); |
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 | |
global $post; | |
$slug = $post->post_name; |
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 | |
$meta_query_args = array( | |
'meta_query' => array( | |
array( | |
'key' => 'my_date_field', | |
'value' => array( strtotime('2022-01-01'), strtotime('2022-12-31') ), | |
'type' => 'numeric', | |
'compare' => 'BETWEEN' | |
) | |
) |
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 | |
$meta_query_args = array( | |
'meta_query' => array( | |
array( | |
'key' => 'my_date_field', | |
'value' => array( '2022-01-01', '2022-12-31' ), | |
'type' => 'date', | |
'compare' => 'BETWEEN' | |
) | |
) |
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 | |
// Increase the image resize threshold to 4000px on the longest edge | |
function smartwp_big_image_size_threshold( $threshold ) { | |
return 4000; | |
} | |
add_filter( 'big_image_size_threshold', 'smartwp_big_image_size_threshold', 999, 1); |
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 | |
// Disable WordPress' automatic image scaling feature | |
add_filter( 'big_image_size_threshold', '__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 | |
// Ensure user is logged in | |
if( is_user_logged_in() ) { | |
// Display current logged in user's avatar (includes <img> tag) | |
echo get_avatar( get_current_user_id(), 96 ); | |
// Display current logged in user's avatar URL | |
echo get_avatar_url( get_current_user_id(), array( 'size' => 96 ) ); | |
} |