Make EMBEDDED WordPress Load Faster
-
Hi! I have my own domain and hosting. I can’t provide a link. I wanted to use WP solely for displaying news on my site. I don’t want to use WP as my site or make WP resemble my site. I just wanted to embed posts from my WP into my pre-existing site.
I figured out how to do that using the loop exactly as described in documents and other tutorials, but the post loads ridiculously slow. The page itself loads lightning fast as expected since it’s just some text and an image, but it takes 10-20 seconds for the embedded post to load, sometimes more.
Since I only have three posts total in my WP and they’re each only 2-3 paragraphs (the loop is set to display only the latest one), I don’t understand why it takes so long to load.
This has been the case since I first did it over a year ago, so the version of WP I’m using doesn’t make a difference because I always update to the next one.
All the topics I find about speed are for people using WP itself, not people like me who are embedding posts from their WP into an html page.
Any thoughts on what else I can do to get it to load quickly?
-
If you’re bringing in content from an external site, cache them. There’s no reason to reach out to the WP site each time your site gets hit.
If you’re bringing in content from an external site, cache them. There’s no reason to reach out to the WP site each time your site gets hit.
Thanks! Just to clarify, I have WP installed on my server and I’m using the loop to display the posts. How do I set it so that it will cache them? Is that something I’d have to change in the loop code or in the WP files on my server?
I do not understand. You’re trying to import this into an HTML page, so what does the loop have to with anything?
https://codex.ww.wp.xz.cn/Integrating_WordPress_with_Your_Website
I have my own website with my own hosting and domain. I installed WP on my server but I don’t actually use the blog. I don’t want to edit the WP files to get the blog to look like the rest of my website, I don’t want it to have its own standalone page, and I don’t need all of WP’s features. All I need is the content of the posts.
So instead of displaying the actual blog, I chose to integrate the posts from it into a page on my site using the loop and made the appropriate changes so the server would tell that HTML page to properly render the PHP.
It works as intended. Whatever the latest post is that I create in my WP admin is embedded in that HTML page, but the post takes forever to load and I’d like to know if there’s something I can change to speed it up.
You’re saying to cache it. Cache what where and how? You asked what the loop has to do with anything. Everything I’ve ever found on the subject, including on here, said there’s no way to embed WP posts directly into a page on your website except by using the loop to call and display the posts. That’s why I’m using the loop.
Is there something I’m missing?
How are you bringing the posts into your non-WP site?
I’m not sure what you mean. I posted how in my last reply. I use the code for the loop to pull and display the posts.
https://codex.ww.wp.xz.cn/Integrating_WordPress_with_Your_Website
So each time your HTML page is hit, you load wordpress and fetch the most recent posts. That seems pretty inefficient. If you want to continue that way, strip down your WP installation as much as possible and optimize its database. There are several mysql tuning tools out there.
By coding a loop directly, you’re going around any caching mechanism on the WP side. Can you do what you want using RSS instead of coding to the WP database?
I looked for ways to do it with RSS before using WP’s own integration method and I couldn’t find anything that didn’t require unreliable third-party plugin/software to be installed and configured that still limited how the post would be displayed. In addition to requiring learning or adding way more coding than it was worth for an end result that still wasn’t neat and fully customizable in appearance with pure css.
WP’s integration method allows me to call exactly the post(s) I want and to have full control over how it displays with just a few lines in the same way the blog itself does. It’s so far been the simplest, cleanest way to do it. That’s why I was wondering if there’s another way to speed it up.
Both the blog and my HTML page are pulling and displaying posts from the same place in the same way. If there are cache features built into WP that make it happen faster with the blog itself, I can’t imagine there isn’t a way I can tap into that. Where in the installation files would there be anything to do with caching?
Nevermind. Since there’s no discernible difference between the php code being used in the blog pages versus me using it in my HTML page since it’s all calling back to the same place, I copied the code from my WP files that displays the blog’s sidebar and pasted that into my HTML page so it would display the sidebar contents. Then I added a widget to the sidebar that displays my latest post.
It doesn’t allow me to display the post itself in full with images and everything like I can with the loop or to customize the look of it 100%, but it at least shows a snippet with a link and loads quickly. I’ll just use this for now until I can find a way to call the individual posts faster.
Thanks!
The topic ‘Make EMBEDDED WordPress Load Faster’ is closed to new replies.