retrieve the oldest post id

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

Why does the page/post ID keep growing when i refresh the post-new.php file?

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().

Categories id Tags

Help getting previously visited pages ID

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.

Set post tags using tag ID

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

Why I can not I use the variable outside my function?

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

how would i change post->ID to work correctly when querying pages?

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/