Modify Templates – Readme

Note: for modifying styles, colours, layout etc (i.e css declarations) please see the appropriate “Modify/Edit Styles/Layout” section in the documentation

Generally, WPPizza layout – i.e html – elements can be modified by using filter hooks provided or – in the case of the loop/menu items – by simply using shortcode attributes to re-order elements as necessary (see shortcode documentation for details).

If at all possible, I would advise you to use the provided hooks for any adjustments you might want to make where ever possible as over time additions might be made to those files you will not be able to take advantage of if you are using your own copies without having to re-apply your changes every time the plugin gets updated.

Furthermore, your email and print templates are directly accessible from WPPizza -> Templates using drag and drop and css declarations per template (if using the “html” template type). Note: “Plaintext” templates are not stylable and will only allow setting the sort order of elements.

Using actions/filters – recommended and preferred way

  • For a list of hooks available – with accompanying examples – please refer to the relevant section from the navigation menu.
  • IMPORTANT:
    When you filter things, do NOT remove or replace any existing classes or id’s from elements. The functionality of WPPizza relies on them.
  • If you need to have a need for your own classes, add them instead

Editing files directly – only if filters/actions cannot be used

If, for whatever reason, you feel you must edit templates directly you should do the following so subsequent updates of the plugin do not overwrite any edits you may have made

  • CREATE the following directory structure in your child theme (see notes below): /[abs-path-to-wp-content]/themes/[my-child-theme]/wppizza/markup/.
  • COPY the relevant file from /[abs-path-to-plugins]/wppizza/templates/markup/[choose-directory]/[choose-file.php] to the directory we have created above, keeping the subdirectory structure intact.
  • EXAMPLE: if you wanted to edit the template element that displays the “cart is empty” in your WPPizza shoppingcart, copy /[abs-path-to-plugins]/wppizza/templates/markup/cart/cart.empty.php to /[abs-path-to-wp-content]/themes/[my-child-theme]/wppizza/markup/cart/cart.empty.php and edit as required.
    Please note the change from “templates” in the plugin itself to “wppizza” in your child theme.
  • IMPORTANT:
    When editing make sure to leave the element structure/nesting as well as classnames and id’s intact as many functions rely on it. In *most* cases it is probably ok to – for example – change an “h3” element to a “h4” element, adding additional css classes or perhaps adding another wrapper element. However, if you do any of the above, make sure you test things thoroughly !

Although you could also use your main theme and create the above mentioned directory structure there, using a child theme is by far the better and recommended way to do this – see WordPress Child Themes) as to why.

Editing files directly – Multisite – only if filters/actions cannot be used

First of all, the same recommendations apply to directly editing copies of the template files – i.e use filters/action instead. However, if you do, instead of creating a wppizza directory in your child theme, you could use a directory as child of the wp-content directory instead – especially if you are using different themes for different subsites but want to apply your specific wppizza modifications to all subsites i.e

  • CREATE the following directory structure in the wp-content directory: /[abs-path-to-wp-content/wppizza/markup/.
  • COPY the relevant file from /[abs-path-to-plugins]/wppizza/templates/markup/[choose-directory]/[choose-file.php] to the directory we have created above, keeping the subdirectory structure intact.
  • EXAMPLE: if you wanted to edit the template element that displays the “cart is empty” in your WPPizza shoppingcart, copy /[abs-path-to-plugins]/wppizza/templates/markup/cart/cart.empty.php to /[abs-path-to-wp-content]/wppizza/markup/cart/cart.empty.php and edit as required.
  • IMPORTANT: “wppizza” directories created in [child]-themes will take precedence over directories created as child of wp-content. Only ever one wppizza sub-directory will be read. So if you create a “wppizza” directory in your child theme AND as sub-directory of wp-content only files in the child theme will be read (provided that child theme is active.) Therefore, you could apply filters etc to all your subsites if you add customisations to wp-content/wppizza but entirely overwrite these for a certain [child]theme if you create a wppizza subdirectory there. If you want to have all your customisations you made in wp-content/wppizza applied to your childtheme too, but want to add to it, you must copy everything to your child theme first
  • SUGGESTION: For your own sanity, if you need to apply some global edits as well as some that only apply to a certain subsite, you might want to perhaps consider only using the /[abs-path-to-wp-content]/wppizza/ directory and using conditionals in the files based on blog_id. something like:

    
    global $blog_id;
    if($blog_id == x){
    /* do your thing */
    }