If you ever tried to use an if statement because you wanted to remove an action on a specific page, you would have noticed that it doesn’t work! Why? Because you can’t just start writing if statements in your functions.php file. It has to be tied to an action.
Here’s a simple way to do this with the Genesis Framework.
In my case, I needed one of my post type pages to look a certain way. I could have used is_single but then ALL of my single pages would have been effected!
Here’s what I tried at first:
Everything seemed OK, but it didn’t work??
Well, it was then that I realized in order to use an if statement like this, it has to be in a function. Your functions.php file won’t read this little bit code.
So what action am I supposed to add it to?
The key here is to remember that we’re editing the loop. The post_meta and post_info are all within the loop of the page.
So if we want to manipulate it, we have to add our action to anything that comes before the loop.
Well, being that Genesis is so freaking awesome and has TONS of hooks you can use, I decided to use the one that makes the most sense.
And voilà! Now the remove_action function will only work on the single post type pages!!
Genesis 2.0 Version NEW
Are you using Genesis 2.0? If so, then this is the code you would use.
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 — 1 year 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: 931
By Jonathan Perez — 7 years ago
This is in response to one of Six Revisions latest articles, 8 Things they don’t tell you about being a web designer. Now though the article wasn’t bad, I feel it took a completely wrong approach and if I was trying to decide if I wanted to be a web designer, their article would not have helped me at all!
I remember when I was in high school trying to figure out what I wanted to go to college for. I picked design because of all the cool perks and stories I heard.
Perks like one lady having a limo pick her up to work everyday, free tickets to events, great gifts that clients give for designing something amazing for them.
Stories like you’ll have so much free time, it’s such a lax profession, it’s always changing.
It’s all bullshit! At least for the majority of designers it is.
So let me say I’m sorry to six revisions but this is the Real stuff they don’t tell you. Read MorePost Views: 2,969
By Jonathan Perez — 3 months ago
This is going to be shrot as I haven’t posted in Forever!!! I still gotta set up the podcast page and what not BUUUUTTTTT here’s the quick of it.
Developer To Millionaire is dead. Sorry, just couldn’t keep up with it, life happens, we move on. I got some great content on there, I’ll have to try and put it on the new podcast, but it’s when I have the time.
My new Podcast is on ANCHOR!!! Here’s the link to it:
(The Correct Link, SOrry about that)
It’s also on iTunes and Google and all the fun sites that have podcasts on them as TheJonPerezShow!
It’s fun for me so I talk about anything that’s really on my mind at the time, so check it out and enjoy!!
That’s all I got! Have a blessed day!!Post Views: 411