Before & After the_content

This is a very good code example for putting info before and after the_content:

function wpdev_before_after($content) {
    $beforecontent = 'This goes before the content. Isn\'t that awesome!';
    $aftercontent = 'And this will come after, so that you can remind them of something, like following you on Facebook for instance.';
    $fullcontent = $beforecontent . $content . $aftercontent;
    return $fullcontent;
add_filter('the_content', 'wpdev_before_after');

Code was taken from here.

An Alternative to @import in WordPress Child Themes

I happened to find this by accident as I was creating a child theme to be able to help someone at the forums.

Basically, instead of doing this on the style.css of the child theme:

 * Theme Name: My Child Theme
 * Template: parent-theme
@import url(../parent-theme/style.css);

/* My Child Theme CSS */

Add the following on the functions.php of the child theme:

// Faster than @import
add_action( 'wp_enqueue_scripts', 'my_child_theme_scripts' );
function my_child_theme_scripts() {
   wp_enqueue_style( 'parent-theme-css', get_template_directory_uri() . '/style.css' );

This alternative makes sense and it does work!

The functions.php Dilema

Over the years I have found lots of different solutions and additions to a WordPress website’s functionality using functions.php.  The reality is that I think there has to be a clear definition of when to put code in the functions.php file of a WordPress theme and when to simply create a plugin.

So on that note, here are some interesting posts I have found on the subject and some of the things that I found interesting and worth noting:


Stop adding code to your WordPress theme’s functions.php file

by WP Ninjas

  • If you are comfortable modifying your functions,php file you are fully capable of creating a simple plugin
  • It’s extremely easy
  • It can mostly be copy and pasted each time you want to make a new one
  • Any code you’ve already pasted in your functions.php can most likely be used in a plugin

Read original post

Why You Shouldn’t Use functions.php (And What You Should Do Instead)


At the core of WordPress lies a simple principle: design and functionality should (whenever possible) be clearly separated.

That is why we have themes and plugins; ostensibly, themes are solely responsible for design and plugins are solely responsible for functionality. One should be able to switch themes without affecting functionality, and one should be able to deactivate plugins without affecting design.

Read original post

WordPress Functionality Plugins

by CSS-Tricks

What is a Functionality Plugin?

A functionality plugin is just a plugin like any other plugin you’d find in the WordPress Plugin Repository. The main difference is that it wouldn’t be publicly distributed, because it’s specific to your site. It’s one custom plugin that encompasses all your site’s custom functionality.

Modular Design

If you’re like me and like to keep things neat and tidy, this is a great time to use a modular approach to the code you place in your plugin.

One approach to keep things simple is to organize your functionality into similar groups and give each of them their own file. Then, include those files into the main file of the plugin using PHP includes. Make sure you notate your functions so when you return to them at a later date you know what’s going on.

Read original post