get_post_meta not working with variable as a post_id for dynamically get the postid
You can try to add global $post; on top of your code. But it depends on where the function is called.
You can try to add global $post; on top of your code. But it depends on where the function is called.
WordPress user ID prefix
yes use this code here you can get attachment id if(isset($_FILES[‘myimage’]) && ($_FILES[‘myimage’][‘size’] > 0)) { // Get the type of the uploaded file. This is returned as “type/extension” $arr_file_type = wp_check_filetype(basename($_FILES[‘myimage’][‘name’])); $uploaded_file_type = $arr_file_type[‘type’]; // Set an array containing a list of acceptable formats $allowed_file_types = array(‘image/jpg’, ‘image/jpeg’, ‘image/gif’, ‘image/png’); if (in_array($uploaded_file_type, $allowed_file_types)) { … Read more
Safely changing UserID’s, re-using deleted UserID’s and automatically using deleted userID’s instead of an increment
Consequence of the post auto incrementer off?
Try using this: $post_id = get_the_ID(); OR global $post; $post_id = $post->ID; OR $post = $wp_query->post; $post_id = $post->ID;
You should be able to use get_current_user_id(). Note that it will return ‘0’ if the user isn’t logged in. <a href=”https://example.com/?user_id=<?php echo get_current_user_id(); ?>”>Link</a> Update 2: Got bored, made a plugin: https://github.com/AndyMardell/append-user-id/releases/tag/v1.0.0-alpha Download the zip and install 🙂 Submitted to WordPress but it’s still under review. Installation and Usage: https://github.com/AndyMardell/append-user-id#installation Update: you won’t be able … Read more
How to get the url of the entry in which an image belongs
get_current_user_id() always return 0 in if else statement
Use the the_date() or get_the_date( ‘d/m/Y’, $post->ID ) functions. This will show only the date of your post type. If you are outside the loop, you need to use the second function I’ve suggested with the post id passed as param.