The project I am working on has several templates, some which do not use the main WordPress editor. For those templates, I typically hide the editor via jQuery’s
The problem I ran into was that when editing a page using a template that did not use the editor, then switching the template to one that used the editor, the editor would be broken until the user scrolled, resized the window, etc. This is due to how WordPress 4.0 now resizes the editor window automatically to fit the content in it.
The trick to fix this is to turn the auto resizing off and on again, which fires off all of the auto resize functions. The methods are:
The longer explanation is below the gist.
First I get the elements I am watching or modifying, I then create the function that is going to flip the switch off and on again.
In the function I first see if auto resizing is even on, because if it isn’t, then you don’t need to do this. Next you can see that I have it set to wait 401ms, the reason for this is due to I am using
.slideDown(), which has a default time of 400ms, and I want it to fire after that.
I then listen for the change of the page template select box, and show/hide my editor as needed. I also flip the switch every time there is a change, which may be too much, but it shouldn’t affect any usability.
And that’s it. If you have a better way of doing some of the things, let me know.
When I create a WordPress theme, I like to make things dynamic, clean and easy for the user(s) of the theme. Today I came across an issue where I needed to be able to link back from a single custom post type to the page that is using the template that displays the listing of the custom post type. The page with the template is currently named ‘Portfolio’ and it displays all of the ‘Galleries’, the link will take the visitor back to the ‘Portfolio’ from a ‘Gallery’…exciting!
I could use
get_permalink( ID ) to get the permalink by the ID, or
get_page_by_path( 'Portfolio' ) to get the page (and then its ID) by its name; but what if the user decides to use a different page or change the page name? Then everything goes caca.
Here’s the gist of what I did. Jump to post “Getting a WordPress page by its template”
Coffee is made and knuckles are cracked, I believe it is time for a update to this design. I probably won’t change much visually, but a lot of the back end needs to change. This theme was one of my first ventures into responsive design and Bootstrap, and now I know a few more tricks up my sleeve…and some down time.
I have been working with custom post types in WordPress for several years now, but never really found a suitable solution for ordering any of the default or custom columns properly. By default WP will order all custom post types by date, which sucks if you want them to sort by menu order, their title, or some other custom column you’ve created.
Every tutorial I came across (not to say every single one out there is wrong) either didn’t work for me, was outdated, etc. So, here’s how I just started doing it.
Jump to post “Order columns for custom post types in WordPress”
Apparently the link below is no longer valid. This one should suffice 😉
So, my hero today is this guy: https://forrst.com/posts/How_to_use_a_custom_taxonomy_in_a_custom_post_ty-J71
Basically what I was trying to do, and Austin de Coup-Crank was able to describe, was I have a custom post type with a custom taxonomy and I need the permalink to have both included. With his solution is place, this is how things come out:
or, in more real terms
I had been smashing my head against the wall trying to determine how to get this done, and finally Google paid off. There were tons of blogs, posts, support requests, etc that were all about it from several years ago, but no one really narrowed it down to something as simple as this.