Often times, we want our hyperlinks to stylistically look like a button. Many UI frameworks, including Foundation, Bootstrap, and UIKit, have button class attributes to handle this for you. Okay, how do you add a class attribute to the opening <a> tag of our “read more” link? Let’s use beans_add_attribute() function. We need to know: The ID of the opening tag. Which attribute we want to add something to. In our case, the ID is ‘beans_post_more_link’ and we want to add a class attribute. Depending upon your UI framework (or the styles you built), that class attribute will vary. Let’s […]
Labs
Labs are hands-on coding projects that you build along with Tonya as she explains the code, concepts, and thought processes behind it. You can use the labs to further your code knowledge or to use right in your projects. Each lab ties into the Docx to ensure you have the information you need.
Each lab is designed to further your understanding and mastery of code. You learn more about how to think about its construction, quality, maintainability, programmatic and logical thought, and problem-solving. While you may be building a specific thing, Tonya presents the why of it to make it adaptable far beyond that specific implementation, thereby giving you the means to make it your own, in any context.
Customizing the “Read More” Link in Beans
A common theme customization is to change the “read more” link. The default in the Beans framework is “Continue reading »”. But what if you want to read “Discover more”? How would you do that? Or what if you it to look like a button? How about changing the icon to something else? In this hands-on coding lab, you will 9+ customizations in your Beans child theme to fit your project’s needs while you learn about Beans and UIKit.
Meta Box HTML
When the screen in the back-end renders, WordPress calls our meta box callback, which we called render_meta_box. In your code, that function does the following tasks: Grabs the metadata out of the database. Does processing if you need it. Loads our view file, which gets rendered out to the browser. Make sure you do this episode with me, as I walk through the code, HTML, and thought processes. You’ll see how little code it takes to create the meta box’s HTML. Resources Variable scope when including files (such as the view file) wp_nonce_field get_post_meta
Continue Building the Shortcode
In this episode, we’ll continue building the shortcode for the topic. We’ll look move the while loop to a new function to process the individual FAQs. As we are building, notice that we have a decision to make: Do we display a message when no FAQs are found? Let’s do that. But instead of echoing at each message, let’s make it configurable and give access through the shortcode’s user-defined attributes. Then the author (or you) can turn it off and on as well as change the messages. This is a refactoring exercise for you. We start off by making sure […]
Add a FAQ Feature to the Collapsible Content Plugin – Part 2
In this hands-on lab, you and I will walk through the entire process of adding a new feature to an existing WordPress plugin. You’ll start with the Collapsible Content plugin and then add a FAQ feature to it. This feature will require you to plan, think, and execute building a custom post type, custom taxonomy, advanced SQL queries, custom archive, and shortcode.
Which One to Use?
Which strategy should you use? It depends upon your specific project needs. In each episode, you and I talked about when it’s appropriate to use each strategy. 99.999 times out of 100, you’re going to use strategy 3. Why? It has the following advantages that we’ll talk about in this episode: It’s one line of code It targets the specific page It does not run on every single web page
Strategy 4: Reusable Function
The fourth strategy is to encapsulate the functionality and abstract it away to a reusable function within your child theme. Let’s do this together. While you could add this function to your child theme’s functions.php file, it’s better to build your theme’s in a modular format. Best Practice – Modular Approach Using a modular approach, you will create a folder in the theme’s lib folder and call it structure. Then in the {child theme}/lib/structure folder, create a new file called footer.php. Here is the code that removes the site footer for each of the pages that you specify: You’ll need […]
Strategy 3: Remove All Genesis Footer Actions
Strategy 3 removes all registered event callbacks. Using remove_all_actions(), you are removing or unregistering every single pre-registered event (hook) callbacks. Using this approach, our code then is: When to Use This Approach? This approach ensures that all of the callbacks are unregistered. It ensures that any callbacks outside of Genesis are removed. Why is that important? It ensures there are no wonky or weird renderings in the browser from your theme or plugin. Strategy 2 removed the defaults from the Genesis framework including the opening HTML <footer class=”site-footer”>, the contents of the site footer, and the closing HTML </footer> element. […]
Strategy 2: Remove the Individual Genesis Footer Actions
Strategy 2 will remove the individual Genesis callbacks (hooks) for the site footer. It requires you to create a home.php file in your child theme. This is the file that is called for the Posts’ Page. (If that doesn’t make sense, then you need to go do the Front Page vs. Home Page lab.) Now inside of this new template file, this new PHP file, you will add the individual Genesis callbacks to unregister each of them. Let’s go into the Genesis framework and find each of the hooks. Open up genesis/lib/structure/footer.php. Scroll down and find each of the site […]
Strategy 1: Hide it with CSS
With CSS, you can visually hide certain elements in the DOM. CSS provides the display property, where you can set it’s value to none. What happens? It removes the HTML element from the visual representation for the web page. To accomplish this in Genesis, you will want to open up your editor and then do these steps: Open the style.css file Search for the .site-footer { section in the stylesheet Scroll down to the end of that section to place the code after these styles And then put in the following CSS declaration block Notice that we are targeting the […]