There are advantages and disadvantages of adding custom programming using the Thesis 2.1 custom files which is what we’ve done so far.
The Advantage to Typical WordPress Programming
The advantage is that it uses very typical WordPress programming. If you’ve done any WordPress programming in the past then this is very straightforward. You understand the hooks and filters and you add an action to action hooks, you add a filter to filter hooks.
The only thing that’s different between this and any other theme or child theme you may be working in is that instead of placing in functions.php, you’re placing it in your custom.php or master.php. This makes it very similar to other themes and for that matter, there are tons of tutorials out there about how you customize WordPress with PHP programming.
The only transfer of information you have to make in your mind is that instead of putting it in your functions.php file, you just put it in your master.php file and besides that, it would behave exactly the same way, it’s ordinary WordPress programming.
Disadvantages to Typical WordPress Programming
There are some disadvantages though. The first disadvantage is the one that I was pointing out which is that it’s cumbersome and sometimes impossible for you to apply those filter functions especially to narrow situations.
The original question was, how can I make this only 10 words long but keep it the regular length everywhere else? Well, that’s something that’s very difficult to do in WordPress. The only way really for you to do it is to create your own entirely custom secondary loop and to filter that way. Then to place that custom secondary loop in the file.
Using Thesis Box API for Targeted Custom Programming
Whereas what we’re going to do here is create a box that just lets you change those aspects of the excerpt. So it can be very cumbersome to apply it to narrow conditions and it’s also very cumbersome to make it user editable.
If the person wants to take this and change it from 20 to 10, you have to open up the code, change the code, save it and upload it. There’s no really simple way for them to make this change. Now, if you are a programmer, you know that WordPress has a very well-developed options API that allows you to create an options page for your theme or your WordPress plugin or whatever.
You can create an options page where you can set that information but that is a ton of work, I mean it’s so much easier now than it used to be. In 2.7, it was just tons and tons and tons of work to create options pages for plugins. In 3.6, it’s much much simpler but it’s still a lot of work and a lot to know and learn in order to make the options API work for you.
It’s definitely an advanced technique. In fact, that’s so advanced I’ve never gotten around to teaching it here on the site because there have only been a couple of people who were interested in learning it and it just didn’t ever seem to fit into a schedule.
However, with the Thesis box API, it is very easy to make this apply to narrow conditions. And it is infinitely simpler to make options user selectable so that the user can choose. I only want 20 words in this excerpt, I’ll use 70 words in this excerpt and I’ll use 40 words in this excerpt. And by the way, I’ll have my “Read More” tag look like this and this one and another way, another one and another way and another one.
That is relatively simple to do. Well, compared to regular WordPress, it’s very simple to do. Perhaps compared to doing this, it’s not very simple. This is very straightforward procedural programming that doesn’t take a lot of mind bending to understand how it works. There’s going to be some advanced knowledge and advanced learning that going to take place even though there’s relatively little code you need to do in order to create an options panel that people can make choices from.