Author: Per Thykjaer Jensen

  • Block Based WooCommerce

    Block Based WooCommerce

    These are my research notes about the new Woo blocks.

    By now WooCommerce has changed totally. Now everything is block based, and this will make all editing much more easy – since all is done by drag and drop. Exactly as we know it from the Gutenberg editor.

    Jamie Marshland: 10 minutes Woo Introduction

    Woo Blocks – in ten minutes

    In Jamie’s video you’ll hear that it’s possible to work with categories, keywords and tags in the page templates. Here are a few tips on how to do this.

    Woo Blocks

    Click the button and read more about the new blocks aka “Set up products”:

    Categories, Keywords, Tags

    You can filter by taxonomies. Obbiously we’ll need blocks from a premade template as our model. Here you can eiter use or copy the blocks from one of the filtering templates:

    Click the button and follow the instructions by Woo.

    Woo: Top Ten Blocks

    Top ten Woo Blocks by Jamie Marsland

    Tutorial

    The following tutorial is made in a Kadence Theme. That’s why the Dashboard looks a bit different.

    Jack – Woo shop no plugins
  • The Portfolio

    The Portfolio

    Domain or subdomain?

    • portfolio.yourdomain.dk
    • yourdomain.dk

    You may or may not want to have your portfolio in the main domain. If you want to have your portfolio as the primary thing in your domain, just skip this chapter.

    A subdomain is a subdirectory in the main webdomain. On some web hotels you have to specify such a directory in the Dashboard of the webhotel. This is the case on Simply.com – but not on One.com, where any subdirectory is regarded as a subdomain. Just to mention the usual suspects.

    Prepare a subdomain for the portfolio. Make sure that your new domain runs with HTTPS.

    Create a subdomain on Simply.com. Live session from a Multimedia Design Class: subdomain, and a one-click WordPress installation demonstration.

    Plan Content

    What kind of content do you need for the portfolio? Rearch and brainstorm. On most portfolios you’ll see pages like:

    • About Me
    • CV
    • Contact
    • Gallery
    • Projects
    • Blog – with amazing news about your projects here and now
    1) Creative Process

    It does not harm to be well prepared. Go through the steps from idea generation to actual wireframes. When you have a clear idea about the content of the site continue.

    2) Create Dummy Pages

    Create the pages, but in this phase just add dummy content. If you have the pages it is easy to create a navigation.

    AI can be a great headstart for dummy content creation. Later on you can modify to real content.

    3) Navigation

    When the dummy pages are made, it’s more easy to create the navigation menus. You can have as many as you want to, and style them according to their position in the design.

    Create the main navigation menu for the header. You may also want to create special menus for other pages.

    4) Choose a theme

    Find a good WordPress theme, and make sure that it’s a block based theme (not an old style PHP-theme). My recommendation is to stick to a standard block theme.

    Avoid crap “freemium-premium” themes. They will hinder you from adding anything interesting untill you pay.

    I’ll recommend either Twenty Twenty Four or the most recent WP standard theme.

    If you’re an ambitious Multimedia Designer of course your could try to create a theme via Carolina Nymarks theme generator.

    Your content will not be affected by the theme. If you want another look and feel just try another theme.

    5) Header, Footer, etc.

    One of the first things to tweak is the header with navigation and footer with the relevant information.

    6) Templates

    Probably your theme will have templates for pages, posts, categories, search and 404. Often a blank theme will come in handy – or perhaps a page with:

    • Header
    • Content block
    • Footer

    Such a page would be nice if you don’t want to be restricted by your theme.

    7) Assign templates to your pages

    When the templates are ready, open each page and make sure that it will use the correct template.

    8) Refine the Content

    You can create the content at any time. From now on it’s a matter of refining your content.

    9) Testing, Testing …

    At any stage of the development tests will improve your portfolio.

    • Usability tests
    • User experience tests
    • Guerilla tests
    • Gangster test
    • A/B split test etc.
  • Responsive Styles

    Responsive Styles

    A while after your theme has been installed, you should inspect how the theme behaves on different devices. Problably the theme needs at least some responsive adjustments.

    Tweak Flexbox

    When you edit the theme files you can add responsive styles to the style.css or a CSS made via a plugin, like these:

    @media only screen and (max-width: 600px) {
    	/**
    	* Add the class noFlex to a group
            * or row that should not flex
            * on smaller devices
    	*/
    	.noFlex {
    		display: block !important;
    	}
    }

    If you have say a row that displays flex on smaller devices, you can add the class noFlex in the Advanced field of the relevant block.

    Try to rezise your browser window here 😉

    Important

    If you edit the style.css of the theme directly inside wp_content/themes/yourTheme/style.css the code will not be saved in the theme.

    In a case like this the best approach is to:

    • Enable another theme
    • Delete the theme
    • Reinstall the theme with an updated style.css
    • Activate the theme.
    • Now the responsive rules will be part of the style.css

    For unknown reasons WordPress does not export your changes if this is not done. I’m not sure whether this strange behavior is a bug or done deliberately.

  • Bitter Font

    Bitter – the font only works in the TT4 style “Permutation”.

    Because that’s where it is!

    Method:

    1. Creata a style in /styles/
    2. e.g. myStyle.json
    3. Download the font from Google Fonts: Bitter
    4. Convert to woff2 with a converter like this.
    5. Place the files in ./assets/fonts/Bitter
    6. Add the file manually to myStyle.json
    {
    					"fontFace": [
    						{
    							"fontFamily": "Bitter",
    							"fontStyle": "normal",
    							"fontWeight": "400 700",
    							"src": [
    								"file:./assets/fonts/Bitter/Bitter-VariableFont_wght.woff2"
    							]
    						},
    						{
    							"fontFamily": "Bitter Italic",
    							"fontStyle": "italic",
    							"fontWeight": "400 700",
    							"src": [
    								"file:./assets/fonts/Bitter/Bitter-Italic-VariableFont_wght.woff2"
    							]
    						}
    					],
    					"fontFamily": "\"Bitter\", sans-serif",
    					"name": "Bitter",
    					"slug": "bitter"
    				}
  • How to Create a Custom WordPress Block Theme

    How to Create a Custom WordPress Block Theme

    How to Create a Custom WordPress Block Theme

    Why create your own theme?

    There are more than 6000 themes for WordPress, why should you then attempt to make your own?

    • As a Multimedia Designer you must be able to develop themes in WordPress.
    • When you know the code, you can modify anything.
    • You are not caught in the nasty “free-but-in-the-PRO-version-you-can” trap.1

    Step 1) Create the theme via a theme generator or boiler plate

    This will give you a fast track devolopment, since most of the files are ready. I recommend Carolina Nymarks excellent Block Theme Generator. Click the button below to get started. If this is your first time, use the basic theme. It is a very good starting point.

    In this tutorial you will learn the basics of block theme creation in WordPress, but if you want to study the subject in depth Carolina Nymark’s tutorials and documentation on WordPress full site editing is among the best sources about block theme development.

    Now you can install the theme by the zip-file. This will create a directory in your WordPress installation:

    WORDPRESS/wp_content/themes/YOUR-THEME-HERE/

    Unzip

    As soon as the zip is downloaded, unzip it somewhere convenient. Open the directory in Visual Studio Code (or another editor) and have a look at the files.

    Open: style.css

    You will not see a lot of CSS here. There are some comments. They will tell WordPress the name of your theme, and give the texts for the descriptions that you see in the Dashboard > Appearance > Themes.

    Step 2) Add a blank template for your design experiments

    In your favorite editor, say Atom, Visual Studio Code or whatever, create a file named blank.html with this markup:

    <!-- wp:post-content /-->

    Now save blank.html and upload the file to:

    (theme)/templates/blank.html

    If you want a page with no design whatsoever you can asign the blank template to the page.

    Now you know how to add tempates to a block theme.

    theme.json

    As a web designer you might expect that the CSS styles should be found in style.css. But in a block theme most styles are defined in the more advanced theme.json file.

    [icon name=”skull-crossbones” prefix=”fas”] Bugs Warning!

    In JSON it is sooo easy to make errors.

    – So make sure to have a back up of your theme.json.
    – Edit your code in e.g. VSC or Atom.
    – Bugs will cause weird behaviors in the theme.

    Staghorn beetle drawing, bug vintage

    In the following steps we will add colors, gradients and even web fonts and also use them to style some of the blocks.

    Let’s open theme.json in our editor and begin with some colors.

    Step 3) Colors

    More than often designers choose five or more colors for their design. You’ll probably know several color pickers, like:

    During the creation of the theme you already selected a five colors. You can select these colors in the Dashboard, for instance when you select the color of a text. You can add more colors for the Dashboard in theme.json.

    The color picker from a theme. But we want more options!

    But you’d probably want more colors. In theme.json you can add more colors like this:

    Color Palette

    In theme.json the color palette is placed under settings.color.palette.

    Since the colors are in sharp brackets, it’s an array. And you can add more colors to this palette. Let’s say that I want to add a green grass color:

    "palette": [
    {
    "color": "#ffffff",
    "name": "Base",
    "slug": "base"
    },
    {
    "color": "#000000",
    "name": "Contrast",
    "slug": "contrast"
    },
    {
    "color": "#89CFF0",
    "name": "Primary",
    "slug": "primary"
    },
    {
    "color": "#5DFCC1",
    "name": "Green grass",
    "slug" : "greenGrass"
    }
    ]

    In the CSS the color #5DFCC1 will be assigned to the variable:

    var(--wp--preset--color--greenGrass)

    You can use this variable in additonal CSS or when you style the blocks (see: “Modify the blocks“).

    In the Dashboard the color will be visible too. So you can of course also use your colors when your work in the editor.

    Exercise

    • Add one or more colors to your theme.json.
    • In the Stylebook: add your new color to one or more selected elements.

    Duotones

    Duotone can be used to tint images with two color hues. By Duotone you can create a consistent design, where images are toned. You can add more duotone filters here:

    Dragon Spacecraft Prepared to Resupply International Space Station
    Duotone applied to an image. Source: Dragon Spacecraft Prepared to Resupply International Space Station by NASA’s Marshall Space Flight Center is licensed under CC-BY-NC 2.0

    settings.color.duotones

    "color": {
      "duotone": [
    {
      "colors": [
      "#6c5513",
      "#067f0a"
    ],
    "name": "Secondary and primary",
    "slug": "secondary-primary"
    },
    {
      "colors": [
      "#067f0a",
      "#f0f0f0"
      ],
      "name": "Primary and Contrast",
      "slug": "primary-contrast"
    }
    ]
    }

    In the sample above you see how the color pair is defined. It has a name and a slug. The name will be visible when you hover over the duotone in the WP editor. The slug can be used as a CSS variable or when you write additional CSS.

    Exercise

    Add one or more duotones to your theme.json.

    Gradients

    Duotones use a two-color array. The gradients may use many more colors. They are also added to the color section:

    settings.color.gradients

    A single gradient may look like this:

    {
    "gradient": "linear-gradient(#067f0a 49.9%,#fff 50%)",
    "name": "Primary color to white",
    "slug": "primary-white"
    }

    Again the name is what you see in the editor. The slug will be used in CSS as above mentioned.

    Step 4) Fonts

    Add fonts, and select them in the editor.

    You can use several standard fonts or choose to add web fonts from files. Fontfamilies are added here:

    settings.typografy.fontfamilies

    See the sample here:

    In this way you can add standard web fonts.

    {
    "fontFamily": "\"Times New Roman\",\"New York\",Times,\"Noto Serif\",serif",
    "name": "Serif",
    "slug": "serif"
    },

    In additional CSS you can then use the font via the slug:

    var( --wp--preset--font-family--primary )
    

    Exercise

    • Add one webfont to theme.json.
    • Use the font on a paragraph or headline
    • In the Stylebook: add the font to a selected element.

    Add a Webfont

    Webfonts are font files downloaded from the web. You can place the fonts in the theme in:

    (theme)/assets/fonts

    and then create a directory for each font.

    In general it is recommended to use the .woff2 file format. If you download the fonts from google or other sources you can convert the files with this tool:

    Addding webfonts will take a few more codelines, see:

    You link to the font file like this:

    "fontFace": [
    						{
    							"fontFamily": "Open Sans",
    							"fontWeight": "300 800",
    							"fontStyle": "normal",
    							"fontStretch": "normal",
    							"src": [ "file:./assets/fonts/open-sans.woff2" ]
    						}

    Now try to add a webfont (and yes, you have to write “file:./” before the path to the file 😉

    Step 5) Use CSS variables with elements and blocks in theme.json

    Here are two samples

    In theme.json you can modify the styling of these elements and blocks:

    • button: Applied to <button> elements and button-like links, such as that used for the Button block.
    • caption: Applied to media captions, which are wrapped in a <figcaption> element.
    • cite: Applied to the <cite> element when used for citations, such as
    • heading: Applied to all heading elements from <h1> through <h6>, but these can be overridden for individual headings.
    • h1 – h6: Each of the <h1> through <h6> elements can be individually styled.
    • link: Applied to the <a> tag, which is used to create links

    From the styles you created so far you know, that the slug will create a CSS variable that may be used by an element or a blog.

    This is done in this section of theme.json:

    settings.styles

    This is how you style a typical block, in this case tha code block. Note how the variable is invoked:

    "styles": {
      "blocks": {
         "core/code": {
            "color": {
               "text": "var(--wp--preset--color--contrast)"
    }
    },
    ... etc ...

    Step 8) Define your frontpage

    You can assign a page as a frontpage in several ways.

    Set the frontpage in Settings

    In the Dashboard click:
    Settings > Read

    In the dropdown menu you can choose the Page that vill be your frontpage.

    You may also want to choose a Page, that will be the placeholder for your blog posts (i.e. news flow)

    Set the frontpage via a template

    If one of your templates is named frontpage this template will define what your frontpage looks like.

    Step 9) Add Static Pages

    Now the work in Visual Studio Code is probably done. However, sometimes you may want to add more features to pages and templates. But for now we’re done.

    Now we will add some pages, like:

    • My frontpage
    • About Us
    • Contact
    • Blog (as a placeholder for the menu)

    Step 10) Add Navigation Menus

    Add the navigation menu. Follow the steps from the previous tutorial:

    Step 11) Add Posts

    If you have made a page named blog add it to the menu (if it is not there by now).

    Now you can add posts – so whats going on in your life?

    Step 12) Theme Modifications in the Style Book

    The Stylebook is a cool feature in WordPress. Here you can see – and even modify – all the components in your style. In the Dashboard you find it in:

    Appeacrance > Editor > Edit

    Then click on the eye-looking symbol:

    The Stylebook with all the styles.

    If you want to edit one of the styles, click on it. Then you can style the components:

    Here the component Headings is styled by one of the theme colors. You can also change the size, typograpy and more.

    Step 13) Export the theme

    And now your blog begins to come alive. But if you added changes via the Stylebook you may want a copy of your theme.

    In the Stylebook click the kebab menu on the top right. Then you’ll see the following menu:

    Export Theme – click on Export.

    Then this menu will pop up:

    Export menu. Name your file.

    Now you can name your zip file. And now you’re in for a treat. Because if you created additional colors in the Stylebook, styled something – or even created template or template parts – they will be part of your theme.

    If you unzip the file you’ll have a complete theme – with an updated theme.json.

    [icon name=”github” prefix=”fab”] Upload your theme to your Github repository!

    Yeah!

    Step 14) Add Styles and Scripts [optional]

    The last step is optional: but sometime you might want to add libraries and additional stylesheets to your WordPress.

    Perhaps you want to add animation libraries like Rellax.js, or features like jQuery or Bootstrap. You can add such scripts in functions.php.

    Enqueue scripts in functions.php

    function petj_mega_menu() {
      // a css file
      wp_enqueue_style( 'CSS_Mega_Menu',
        get_template_directory_uri()
        . '/assets/css/css.css' );
        // below a script
        wp_enqueue_script( 'JS_Mega_Menu', get_template_directory_uri() . '/assets/js/js.js', array(), '1.0.0', true );
    }
    add_action( 'wp_enqueue_scripts', 'petj_mega_menu' );

    Here you can see that a CSS is added via the function wp_enqueue_style and a JavaScript is added to the theme via wp_enqueue_script.

    The path to the script or file is creates by get_template_directory_uri():

    get_template_directory_uri() . '/assets/js/js.js'

    In PHP a dot will glue two strings together so the last part is simply the part from the theme folder to the JavaScript: ‘/assets/js/js.js’.

    Allergy crying eye png sticker

    Step 15) Backup

    This part is not strictly part of theme creation, but you need to backup your work on a regular basis. Your content is not part of the theme. You need a backup of both your files and of your database.

    Backup A) All Files

    Copy all files from the WordPress directory. Save them on your computer. After download you may want to zip the files.

    Backup B) The Database

    Export the database in PhpMyAdmin on your webhost. Here is what it looks like on my webhost Simply.com:

    Exporting SQL from PhpMyAdmin on Simply.com. Most web hosts have PhpMyAdmin. Export all tables connected to your wordpress installation.

    Save your files and the SQL file somewhere secure.

    Restore a Backup

    Often the webhost has a backup system. Before you panic and try to restore your backup – see if you can restore your website on the webhost.

    If not the last option is this:

    • Open PhpMyAdmin and select import. Then import your SQL-file.
    • Then upload all the WordPress files via Filezilla or the file administration of your webhost.
    1. More than often such themes or plugins may block something that should be free and easy to do. As an example Astra once blocked custom HTML, so test themes before they fool you! ↩︎
  • WordPress: How to Solve Cache Issues

    Sometimes you’ll see that your corrections to CSS or scripts don’t seem to work. If it is not an issue with your code, perhaps the problem is cashing either on the server or in the browser.

    To me the best cure of caching issues is:

    1. Use a plugin to clear the WordPress cache
    2. The problem can be the browser cache, cure: Use a browser window that is not cached – e.g. a Fire Window in the DuckDuckGo browser, a private window in Chrome or Firefox.
    3. Sometimes you have to use yet another private / fire window in order to see the changes!

    Here is a good article about cache issues when you develop WordPress.

  • Mega Menu III

    Mega Menu III

    Continued Megamenu Experiments

    The medieval philosopher Occam said, that if there are more solutions with a similar result, then the most simple one is the best. Then what is the simplest possible Megamenu for WordPress.

    Here is the simplified code for a Megamenu:

    Now it should be possible to build a template with a Megamenu. The scripts and CSS should be loaded via s plugin – or if it’s a theme from scratch via functions.php enqueues.

    If you can create solution with fewer lines of code, let me know in the comments.

  • Taxonomies: filter by Category or Tags

    Taxonomies: filter by Category or Tags

    Below you see two columns. One with texts from the English. To the right Danish articles. It’s made by two Query Loops, one for each category. In this way you can create multilingual sites.

    Category: English

    Category: Dansk

  • Mega Menu 2

    Mega Menu 2

    My Mega Menu will appear above this post when you hover over “Dropdown” – or click on it.

    Insert the wanted menu somewhere. Make sure to adjust the menu’s behavior. Select the block in Document Overview. Then copy the block.

    Now in the editor – paste the code. You will get something along these lines:

    <!-- wp:navigation {"ref":62,"overlayMenu":"never","layout":{"type":"flex","justifyContent":"center","orientation":"vertical"}} /-->

    How to Create a mega menu

  • Marsland: Changes Coming to WordPress in 2024

    New features in WordPress by J. Marsland.

    A few of the news are:

    • Native custom fields
    • Font Library (so the themes.json method was too cumbersome)
    • Navigation improvements
    • Real time collaboration prototype (available via the Gutenberg plugin)

    Now we’re at it:

    Typical Beginner Errors

    Yet another useful Marsland video. Most beginners make these errors.

    Marsland suggest this workflow:

    1. Don’t put the actual page content in the Site Editor.
    2. Create two new pages, your home page and block/posts page as set in reading settings as normal.
    3. Edit the home page template in the Site Editor to create your blog layout.
    4. Create a new Front Page template in order to design your front- og homepage.
  • Matt Mullenweg: State of the Word 2023

    Matt Mullenweg: State of the Word 2023

    In this video from Madrid the inventor of WP Matt Mullenweg presents new trends and options with WordPress.

    Trend: WP Playground

    One of the most exciting news is the WP playground. Now you can develop a WP solution – with PHP and plugins – in the browser.

    Try WP Playground!

    Trend: AI

    Matt made an AI demonstration of multilingual sites. A speaker talked in several languages, and the lip sync was attempted. This technology is in it’s infancy, however the results are very promising.

    TT4

    The theme for the next year was demonstrated by Mullenweg and the lead developer of Gutenberg Matias Ventura.

  • Fonts in theme.json

    Fonts in theme.json

    How to add fonts to a WordPress theme in the theme.json or style.json. Here is the JSON.

    Place this object in in settings.fontfamilies:

    "fontFamilies": [{
      "fontFamily": "PermanentMarker",
      "name": "PermentMarker",
      "slug": "PermanentMarker",
      "fontFace": [{
      "fontFamily": "PermanentMarker",
      "fontWeight": "400",   "fontStyle": "normal",
      "fontStretch": "normal",
      "src": ["file:./assets/fonts/Permanent_Marker/PermanentMarker-Regular.woff2"]
      }]
    }]

    The file format .woff2 is recommended, however you can have fallback files in the array with the path to the font-file.

    Bug (WP 6.4.2)

    However, there is a bug in WP 6.4 – if you try to use this font in headings you cannot save it. I hope that this will be corrected soon. You can use the font in the Gutenberg editor, but not assign the font to the headings.

    Here I add the font:

    The font is visible in the editor. However, as soon as I press “save” the font is gone! And everything is back to “normal”:

    Bug Report

    Here is the bug report in Trac.

Enable Notifications OK No thanks

We use cookies - more information

Multimusen.dk will set a few cookies from Doubleclick, Google and the Social Media plugins they ay set some cookies. Some of my pages use APIs - such as YouTube, LinkedIn, Google Fonts, Google Maps, Mapbox, Spotify, Jetpack, Twitter, Facebook &c.. Such plugins may set the odd cookie.

Close