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 — 2 years ago
I use Toolset all the time. One thing that constantly annoys me is when I need to create a simple grid loop. For some reason, Toolset loves to stick with tables as a grid format, unless you’re using Bootstrap. Well, I don’t want to use Bootstrap. I use Genesis.
So here’s a simple way to get your grid loop working with Genesis and any other theme for that matter.
What Views Gives You
When you go into views, and you’re getting ready to create a loop, you get the options of “Unformatted, List, Table Grid, Bootstrap Grid, etc.” Bootstrap grid, however, is blocked out because it knows that you’re not using Bootstrap. You’re damn right I’m not! (I like bootstrap, but I use Genesis)
So when you select the table grid, here’s the mess that Views gives you.
Let’s fix it and use the classes that are already included in the Genesis Framework.
Yay!! Now it’s clean. Here’s a quick explanation of how this grid works.
How The Grid in Views Works
The first part of the grid looks like this:
That means that it’s the first cell or the first place in your grid. So if you’re doing a grid with 3 columns, this indicates that it’s the first placement of your grid.
The second key factor in this setup is
This is equal to all the in-betweens in your grid set up. So if you have 5 columns, 10 columns, or 3, the index=other is everything in between the first and last column.
Next, you have
The three in this fancy little shortcode is the last column. You can make it whatever number you want, but keep in mind that this will be the last column in the grid.
I’m going to group the next two gems together. They are:
This little gem is the filler for when your grid ends. If you have a grid with three columns, but you only have 7 items. That’s going to throw the grid off.
So pad, once again, is the in between fluff. Similar to index=other except that, it’s empty. You may have already guess what pad-last is, but if not, it’s the last empty shell in your grid.
The point of the padding is if you have a background color or things that you need to clear, you can do it in the last empty column and continue the look of your grid without having it break the grid itself.
Isn’t views awesome! 😀
Have any other cool methods for a grid? Let me know in the comments. Otherwise, enjoy!
What’s that? You don’t have the classes! No problem, here you go!Post Views: 1,664
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,602
By Jonathan Perez — 6 years ago
There are so many tools available for to make awesome websites! Everything from free fonts, amazing text editors, style sheet awesomeness, plugins and the works!
Here’s my insight on the future of web design tools and what’s happening. Read MorePost Views: 1,818