Trying to get post ID outside loop on blog page
Trying to get post ID outside loop on blog page
Trying to get post ID outside loop on blog page
For Googlers looking for a solution after hours of research spl_object_id is your solution. Read more here: https://www.php.net/manual/en/function.spl-object-id.php Example: <?php $id = spl_object_id($object); ?> <div id=”carousel<?php echo $id;?> class=”carousel”>
How can I remove WordPress element IDs and Class names in the HTML?
Ad units Div-ids frequently changing
WordPress Post ids big increment
WordPress already has current-menu-item class. Following CSS can be applied. .current-menu-item{ background-color:#4ba668; color: white; display:block; } Thanks to bosco for his comment.
$term = get_term_by( ‘name’, ‘Дома 5, ‘category’ ); echo $term->term_id;
You’re running your code on the wp_loguout hook, which is after the user has logged out, so of course there’s no current user ID. There’s no current user at all. If you look at the documentation for the wp_logout hook, you will see that the ID of the user that was logged out is passed … Read more
You can add a low priority authenticate hook that runs after all the other hooks and rejects authentication for a specific user ID: function wpse_384212_ban_user_id( $user, $username, $password ) { // At this point $user is either a WP_User object if they’ve successfully logged in, // or null or a WP_Error if they haven’t. We … Read more
Custom Post Type with Sequence ID