The WordPress wpdb class is a little different than the normal way of querying in that you run “vanilla” database queries.
You can see documentation on the wpdb class on the WordPress docs: http://codex.wordpress.org/Class_Reference/wpdb#Run_Any_Query_on_the_Database
Also, in regard to your code, you should be able to change the line here:
$originaldb->query_posts( 'posts_per_page=1' );
To something like this:
$results = $originaldb->get_results( "SELECT * FROM $wpdb->posts LIMIT 1" );
This will provide you with an array of posts that you can then process with a loop:
if($results):
foreach($results as $post): setup_postdata($post);
// do stuff with normal wp template tags
endforeach;
else:
// no posts
endif;
Related Posts:
- Maximum number of posts per page before affecting performance?
- How to get posts published on the latest date?
- The_excerpt() doesn’t parse – how to change that?
- Trying to edit archive.php to only show post extract, with featured image
- Add Blog to WP homepage Manually
- How can I remove the first two words and shorten get_the_title()
- How to only publish posts with image in it
- How to show all posts by author on buddypress profile with navigation
- Page and post loop same template
- WordPress Query Posts From Category Post on Static Page
- ACF to select posts not displaying on blog page
- Add custom text automatically on each post
- Getting blog pagination to work on page set as front page
- Extracting relevant tags associated with that particular single post only
- Make loop inside slider divisible [closed]
- Delete post revisions only for a single post
- How to add automatically bootstrap 4 order-lg-1 and order-lg-2 classes for columns in foreach loop based on the count?
- Why this function doesn’t works without the_post?
- Move posts from a non-wordpress site to wordpress
- wp_posts table extremely large
- Display current post position in Elementor Posts widget
- How to Assign / Move all Deleted post to a category
- Loop through posts? Want to remove extra newlines in actual post HTML/content on backend
- Display post number by category
- Saving Post Data in Another Database
- WP_Query: Show 10 posts in date order, first three random
- How include css class based on post ( in loop ) slug?
- WordPress Loop: How to display recent posts in multiple divs
- Querying another post category to match current post and display in loop
- How to display posts on custom page without declaring a posts page in reading settings?
- Show posts by quarter
- separate the post of a category by subcategory
- How to display post list in a table layout (multiple queries in single loop)
- Restore woocommerce orders
- Cannot implement byline into posts container in single.php
- Not all posts showing in query
- how to handle the loop using filling bootstrap grid structure?
- Optimizing the blog loop
- How to check if there are posts with the same tag
- WordPress loop not working on static front page
- How to select particular month post from table and update the post status using MySQL?
- Accessing Post ID Within Loop
- Some doubts about how the loop work (trying debugging it)
- Custom WP_Query not working correctly
- Different number of posts per row in grid layout
- Optimize CPT-function with a loop
- Display specific posts on home page
- The loop starting at a certain ID
- linking to post outside the loop
- WP_Query of Category Not Showing First Post
- If custom field is empty, use one from a previous post
- Cant’ Grab WordPress Built-in Posts Through Loop
- Update field in database for users
- How come this loop is not working? [closed]
- Loop not showing first post
- Get post category as a separate string and url
- Import custom database into wp and keep the post id
- Limiting the amount of posts retrieved by the loop
- Display 3 posts with different HTML markup using a loop
- Pagination for normal (standard) posts on a page with a custom loop?
- Changing wp_link_pages() to “Next Page” and “Previous Page” buttons?
- I can’t find the relevant part of the loop in my theme file. How do I find the full content with “More…”
- posts going to 2 pages/categories only show up in 1
- How to repeat a loop after 4 posts [duplicate]
- why the posts queried from sql is more than those showed on the page?
- Custom Post Type Single Loop Outputting Wrong Post
- Using the loop to set locations for all posts on a single google map
- How to separate each individual blog post?
- Moved to a new server, backup was a day old and missing 3 posts, anyway to recover them from old host?
- Defining ‘last’ class on foreach blog posts
- Get current taxonomy and display query accordingly
- Is there a function to get post info for any publish_status by post ID?
- How to show full post on home page
- Your ideas on my though “delete or move all of the posts in a specific category when 3 days are passed”
- How Can I Always Display A Particular Post First Using WP_Query?
- Help on conditional statement to accompany wp_insert_post function please?
- Error while excluding a post from another loop (using its ID)
- Is there a way to define the $post var outside the loop?
- How to add content above footer in posts from specific category
- How can I globally italicize list of texts in the UI database or Posts? [closed]
- Is it possible to modify posts table to only read for more recent ones?
- ACF flexible content block not showing on live site (works locally)
- Only the most recent post is showing on my category page (working on localhost, not live site)
- Want to change the post every three days with in specific category
- Separate top level categories on archive-product.php by meta
- While loop in functions.php outputting the_title() of each post on frontpage
- Shortcode for Comments and Comment Boxes in Post Loop
- Permalink Short code showing unnecessary link text inside the loop
- Menu Items disappearing/being empty on save or post edit
- My website is showing today’s date instead of published date since db migration to a new wordpress
- How to setup default value of post_id
- Prevent a post with a specific ID from being created
- Current post categories and subcatecories outside of the loop
- Bulk find & replace on WordPress posts/pages (minus image paths)
- Multiple post in One Loop in wordpress
- Display specific posts based on an ID of another post
- Numbered Pagination Showing The Same Posts After Altering WP_Query
- “read more” redirects to the wrong page
- Diffrent layout for posts [duplicate]
- How to show post views shortcode data for each post on Posts List Page?