Is it possible to get an array of all post IDs currently present in the wordpress DB (irrespective of post_types)? Also, is it possible to get an array of all post IDs of a specific post_type?
If we can, how to achieve that?
Get Post ID Using the get_the_ID() and the_ID() Functions The get_the_ID() and the_ID() functions display the current post's ID. The main difference between the two functions is that get_the_ID() returns the post ID without displaying it, while the_ID() always prints the post ID.
This Post ID is a string of numbers at the end of a Facebook post's URL. The easiest way to find your Facebook post's direct URL is to go to the post itself in your Facebook Business Page newsfeed, and right-click on the date/timestamp on the post and open it in a new tab to go to the direct link of the post.
You can try this way
$post_ids = get_posts(array(
$args, //Your arguments
'posts_per_page'=> -1,
'fields' => 'ids', // Only get post IDs
));
probably best to run a custom query using the DB object of wordpress. (from functions.php or a theme file etc):
// pseudo-code check how to refer to the field columns and table name!
global $wpdb;
$sql="SELECT id, title FROM posts";
$posts = $wpdb->get_results($sql);
print("<ul>");
foreach ($posts as $post)
{
print('<li>'.$post->FIELD1.'|'.$post->FIELD2.'<br/>');
print('</li>');
}
print("</ul>");
I think in fact you can get that also with standard wp_query object.... but at least my way you could make the query in phpmyadmin first, then adjust for the syntax/wordpress prefix. (read the codex on DB object) . If it is a one-off just use phpmyadmin, but for programmatic use you should then convert it to run from your functions.php file.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With