Back to Community

How to Add Custom Code and Shortcodes in Blocksy: A Troubleshooting Guide

27 threads Sep 10, 2025 ThemeBlocksy

Content

Adding custom HTML, JavaScript, or shortcodes is a common way to extend a WordPress site's functionality. However, integrating this code with the Blocksy theme can sometimes be confusing, leading to issues where the code doesn't execute and instead displays as plain text. This guide explains why this happens and walks through the most effective solutions.

Why Your Custom Code Might Not Be Working

Based on community reports, the primary reasons code fails to execute are:

  • Incorrect Placement: Certain areas of a WordPress site, like archive pages or some header elements, are not directly editable through the standard page editor.
  • Theme Updates: Manually editing theme files (e.g., header.php) is not recommended, as your changes will be erased every time the theme updates.
  • WordPress Security: For security reasons, WordPress does not allow the execution of raw PHP code within posts, pages, or many theme options.
  • Plugin Conflicts: Sometimes, a shortcode from a specific plugin may not be compatible with the way Blocksy outputs content in certain areas.

Common Solutions for Adding Custom Code

1. Using the Header HTML Element for Shortcodes

To insert a shortcode into your header, use the built-in HTML element in the Blocksy header builder.

  1. Go to Customize → Header → Header Builder.
  2. Add an HTML element to your desired header row.
  3. In the element's settings, paste your shortcode (e.g., [my_shortcode]).
  4. Important: Switch from the 'Visual' tab to the 'Text' tab before pasting to ensure the shortcode is not altered.
  5. Publish your changes. You may need to refresh the page to see the shortcode take effect.

Note: This method supports shortcodes but will not execute PHP code.

2. Using a Dedicated Plugin for Advanced Code Snippets

For adding PHP code, global JavaScript, or CSS, the safest and most update-proof method is to use a dedicated snippet management plugin like Code Snippets or WPCode. These plugins allow you to safely add code that persists through theme updates without modifying core theme files.

3. Official Plugins for Third-Party Services

For integrating code from services like Google AdSense or Analytics, it is highly recommended to use the official plugin provided by the service (e.g., Google's Site Kit plugin). This ensures proper integration and avoids code being stripped during updates.

What Doesn't Work (And What to Do Instead)

  • Editing Theme Files: Avoid directly editing theme files like header.php or functions.php in a parent theme. Your changes will be lost on update. Use a child theme if you must edit files.
  • PHP in Posts/Header: You cannot directly insert PHP code into the header HTML element or a post. Use a snippet plugin to add PHP functionality.
  • Certain Plugin Shortcodes: If a plugin's shortcode does not work within the HTML element, try a different insertion method or contact the plugin's support for compatibility advice.

Troubleshooting Checklist

  1. Is it a shortcode? → Use the Header HTML element and paste it in the 'Text' tab.
  2. Is it JavaScript? → Use a dedicated snippet plugin or a widget area with a 'Custom HTML' widget.
  3. Is it PHP? → Use a snippet plugin. Never paste it directly into the theme customizer.
  4. Is it for a service like Google AdSense? → Use the service's official WordPress plugin.
  5. Did you refresh? → The Customizer preview may require a full page refresh to render the shortcode correctly.

By following these methods, you can reliably add custom functionality to your Blocksy-powered site without fearing lost code after the next update.

Related Support Threads Support