Why would get_posts be ignoring posts with 2-digit ids?
It might be because you are using numberposts=0 If you want to return all posts then you need to use -1 not 0
It might be because you are using numberposts=0 If you want to return all posts then you need to use -1 not 0
I do not see any problem in your query (except some poor query writing styles). You did not explain ‘does not work’. what you get in return? do you get any errors? Probably you do not have any published job_listing! However, here is how you can improve your given code: $oldest_post_id = $wpdb->get_row(“SELECT `id` FROM … Read more
This is normal behaviour, as I understand it. When you load the page post-new.php, you run this function: $post = get_default_post_to_edit( $post_type, true ); where the second argument stands for $create_in_db. If true then this part is executed: if ( $create_in_db ) { $post_id = wp_insert_post(…); } inside get_default_post_to_edit().
get_page_by_path() should help you here. Something like this <php $prev_url = isset($_SERVER[‘HTTP_REFERER’]) ? $_SERVER[‘HTTP_REFERER’] : ”; if ( $prev_url ) { $prev_path = str_replace( home_url(), ”, $prev_url ); $page = get_page_by_path( $prev_path ); } That should give you the page object, where you can access it’s ID like so – $page->ID.
Using your code you could something like this: function my_custom_admin_head(){ global $post; echo ‘<script type=”text/javascript”> var js_post_id =’ . $post->ID . ‘;</script>’; } And then just use the var js_post_id. You shoudl try to read about the script localization function and use it.
Use pagename instead of page_id to query by slug. Note that if a page is a child of another page, pagename has to be the full parent/child path to the page, since slugs only have to be unique per-level in hierarchical post types. See WP_Query for the full list of query vars.
For non-hierarchical terms (such as tags), you can pass either the term name or id. If you pass the id there is only one caveat: You must pass it as an integer, and it must be in an array. This is necessary because any non-array value passed will be converted to a string, which will … Read more
Maybe I’m missing something, but you seem to have missed one of the most ubiquitous functions in WordPress Core– get_permalink(). The function accepts two optional parameters, the first of which is the post ID. So, to get the permalink via the post ID all you need is $perm = get_permalink($post_ID);. If you just need to … Read more
The problem here is order, the $post variable isn’t available from the moment WordPress is loaded, it needs to process the request, put together a database query, and retrieve the post first. Time travel is necessary for your code to work as you expected. Your themes functions.php and plugins will be loaded before this happens … Read more
Try with get_the_ID() $image_uploaded_meta_id = get_post_meta(get_the_ID(), ‘_listing_image_id’, true); get_the_ID() is a core WordPress function that acts directly inside the WordPress Loop, retrieving the id of the current item being loaded. $post->id is not working because the variable $post has no scope inside the loop. Here’s the link to the documentation: https://developer.wordpress.org/reference/functions/get_the_id/