I’m using a new plugin and need to find the source code of the featured image on the posts. After some research I found this nice little snippet of code and it works GREAT!!! Now I just need to find out how to only get the uri!! Any help would be much appreciated!
$imgsrc = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "Full");
You can also get the width and height by using the array 1 or 2 like this:
$imgsrc returns the width.
$imgsrc returns the height.
About the AuthorWhat's UP! This is my site, I write 99% of the articles on here. I'm also the owner of SureFireWebServices.com. I help out a lot of developers and designers getting into the web game. Helping is fun for me, so feel free to ask me any questions! I've made courses and have a membership as well to help get you on your feet!
You Might also like
By Jonathan Perez — 5 years ago
To run a side business creating websites, there are certain things that need to be used. All of these things make creating websites and running a business exceptionally easy. So here’s a list of things that I use, like, and would definitely recommend to other web creators. Read MorePost Views: 1,586
By Jonathan Perez — 2 years ago
This is a situation that happens more often than not. Some awkward plugin conflict or server error happens and no one knows what the root cause is. How do you fix these issues? How do you even find out what is causing the error. I’ll go over a few ways to troubleshoot the problems and I even added a video that shows me troubleshooting an issue with one of my client’s sites. The funny thing is, depending on the problem, you may get a fake Eureka moment as I did in the vid.Watch on YouTube: http://www.youtube.com/watch?v=dcAwGGwNKVY
What type of conflict are you having?
When it comes to WordPress, I think most conflicts happen when a bunch of plugins are used, and no one audits to check out why or how they’re being used. Most end users, with no restraint, end up installing random plugins to accomplish something they need, but when they realize they don’t need them, they still leave them up.
Sometimes it’s the developer that just starts to install many different plugins that end up not playing nice together.
Besides the plugins that can cause conflict, there may also be theme issues. I had an issue at one point where the developer h
I had an issue at one point where the developer dequeued (or removed what was once there) jquery, and hard coded in a version from Google. This probably wouldn’t be a bad thing, except that jQuery is constantly updated, and the hard-coded version was very outdated, causing new plugins and functions to not work.
The first thing that you would need to do when troubleshooting is to try and figure out what the issue is. A simple way to do that is to check the Developer Console.
I use Chrome and to see what issues may be happening, all you have to do is right-click an area, then select “Inspect”. After you do that, click on the tab called ‘Console’ to see if any errors pop up. Errors will be in red.
Once you do that, you’ll get a better insight on what may be causing the issue.
When there is a conflict, you can move your mouse over the file name to see where the issue is coming from. It’s usually a file, and moving your mouse over it will show the path. If it’s not a file and it just says (index), then that means the error is directly on the page.
If it’s directly on the page, then you’ll need to see what plugin or what area of your site gives access to create code on the page as opposed to in its own file.
In my case, I was trying to find a server error 500.
This has to do almost entirely with your hosting company. Keyword almost. A server 500 error really doesn’t mean anything and most times it’s only temporary, but in my case, it was something that kept happening.
It could be a memory thing, a ram thing, something being updated, it’s a very general error and you’re best bet would be to contact your hosting company.
That’s what I did, and they made some changes which temporarily fixed a few things, but the issue would keep coming back. That led me to believe that it had to be something else.
And that is where the site troubleshooting to fix the error starts.
Steps to Troubleshooting Your WordPress Website
Step 1: Back Up Your Website
You’ll need to make sure that you have a full backup of your website in case anything goes wrong. You don’t want to be stuck trying to retrace your steps and you NEVER want to work on a live site. Back up your website and prepare for a migration.
I use UpDraft Plus and it works like a charm. You can also use BackUp Buddy or whatever backup software you’re comfortable with. Just know that you’re backing it up, and you’ll be copying it to a test server.
Step 2: Migrate the site
I like to put the site in a staging environment, sometimes on my local machine, but most of the time on my own host. I use my own host and a subdomain because it’s easier for me to replicate the issue since it’s on the same exact environment as the website.
Restore the site exactly how it is on the server and start to troubleshoot.
Little side note: Depending on the issue, the main thing you want carried across are the database, the themes, and the plugins. The media is good too if it’s something visual, but sometimes the media folder can be gigabytes of data. So in the spirit of saving time, you don’t need the entire uploads folder all the time.
Step 3: Start with plugins
Before you go and disable every single plugin, keep in mind that there’s a method to the madness. What I like to do is look for the known culprits first, then work backward from there.
A lot of times, the issue can come from caching plugins because of minifying and uncleared cache, so that’s what I look for first. I’ll disable it, then try again and see if it works. Usually that fixes most issues, but it may not, so we continue to move forward.
BTW, My main choice of caching plugins for WordPress is WP-Rocket.
After I disable the caching plugins, I then look to see what kind of plugins are there that aren’t a part of the core functionality of the website. For example, a display author plugin, or a plugin that just does something that the user can live without.
Keeping track of what I’m removing, I disable them one by one, checking to see if it fixed the issue, then go back.
It’s a long, tedious process, but with a little bit of luck, you may find the culprit pretty quickly.
Once you do all the unecessary plugins, now it’s time to start the core functionality plugins. These are the bad boys that run the site. WooCommerce, plus extensions, maybe EDD, or other plugins that the client needs in order to do business or make the site function.
Wash, rinse, repeat.
Step 4: Still Broken!?
What a pain lol. The simplest thing to do now is to reactivate the plugins, and switch out the theme. Use one of WordPress’s generic ones, like 2017 or 2016.
By now, the issue should be resolved and you should have found what was causing the bug with your WordPress website.
How To Avoid Issues for the Long Term with WordPress
If you’re a developer or if you’re someone who has a website, this is definitely something to keep in mind. I found that the best way to avoid issues is consistency.
The Bad Thing
Here’s what a LOT of developers do when someone needs a website. They go onto a theme site, they pick a theme that the client may like (thinking that this is saving them money). The developer then hacks away to get that “theme” to look how the client wants it.
They flood it with plugins to get the right “functionality” even for basic things like simple style changes.
Then they deliver exactly what the client wants, but the build is horribly done, leaving no room for growth or updates. Changes are much more complicated to accomplish costing more and more money for the end user. So they money they think they saved, ends up getting spent on fixes and updates, and sometimes the site has to get a complete rehaul.
Of course, no one likes to here that they wasted a few thousand dollars, but that’s where we are today. The good thing is there are tools that make creating websites super easy, but the way in which sites are built is being taken for granted.
The Good Thing
The ulimate dev stack. This is my suite of tools that I use to build every site I work on. As I said, consistency is key. If you know your tools inside out, you’ll know exactly what works and what doesn’t work, what you can use and what you can’t use, where you can put the website and where you can’t put the website. You get the point.
If you’re a developer, you should definitely check out that dev stack. If you’re an end user, what you really need to focus on is someone who is going to build a site that will be as flexible as your business. Something you can grow with. A consistent set of tools is KEY to avoid so many issues that happen on SO many websites. Otherwise you may be spending a lot more money in the long run, or continue to hack away digging the ditch deeper and deeper.Post Views: 1,992
By Jonathan Perez — 7 years ago
Something that always comes up with web designers/developers is pricing. Why is it that there are people out there that will do a website for a few hundred bucks, and others that charge thousands!?
I used to work for a company where prices were just random numbers thrown together! This is $300 and that’s $1000, but there was absolutely no justification in why things were priced that way.
Here are a few tips that I picked up along my career, that will show you how to price your services better. Read MorePost Views: 3,417