CL 2013-11-24

Now we comes to the last php changes in my template: function.php! It contains several functions to adjust the way my template should behave.

  • To give possibility to have a thumbnail in template – and to specify a size for the thumbnail (for the portfolio projects in the front page), I must add the codes
  • I used a string to add a  class="external" attribute to <a> tags in the main navigator bar – to instruct javascript to let it be a external link and not a internal “one-page” link which we can smooth scroll to (using the Waypoint.js script).
  • I used the function.php to list up all the css and javascript files needed for the template. It’s a good way to enqueue the scripts and styles and tell WordPress which file depends of which (a lot depends on jQuery.js – which WordPress self can provide). If a other plugin have a similar need for a certain javascript file, it could just use the newest. Easy!

    The enqueue function have a lot arguments. First is the name, second the path, third the dependencies, fourth the version of the file – and fifth and last, about the file should be placed in the footer. The style enqueue function only need the two first arguments. The  add_action(); script execute the function and implement the scripts and styles in the template.