Handy shortcode embedding feature for a WordPress site
WordPress, just like other CMSs, offers plenty of built-in features. However, customers can ask for more! For all imaginable wishes, WordPress website maintenance agencies create custom WordPress plugins. Here comes one of the cases like this. Our customer wished to make their content — in particular, quizzes — easily embeddable on their WordPress site. No sooner said than done! WishDesk team created a custom WordPress plugin to fulfil this wish. Read more details right now.
The idea of a shortcode embedding feature
Our customer’s website offered online books to let everyone study. It also offered quizzes to let everyone test their knowledge afterwards.
However, the quizzes were just listed on a page and not added to particular books. Their titles were similar, but that was all. Of course, that was not convenient enough. A tighter logical relationship was needed between the quizzes and books.
Website migration was an awesome opportunity to improve this. When we migrated all 158 quizzes, along with the page that listed them, our customer also wanted to be able to add quizzes to books.
Quizzes or sets of quizzes, had to be embeddable, for example, on the last page of a book or its part, and anywhere else on the website.
Custom WordPress shortcode embedding plugin
So, guided by WordPress plugin creation standards and the best practices of OOP, we created a custom plugin that makes quizzes embeddable via shortcodes. It takes into account the structure of the website’s theme, as well as custom post types on it.
When the plugin is installed and activated, the admin panel shows a special page with explanations and step-by-step instructions on how to embed the shortcodes into website’s content, as well as assign special parameters to them.
Flexible sorting options
We made quiz sorting more flexible by adding unique attributes. Multiple parameters can be combined, which lets you create interesting display logic.
Quizzes can be added to one or multiple quiz types (categories) or to none at all. The Quiz Types metabox is added to the admin panel for this purpose.
Two shortcode types
We created two types of shortcode — “simple quiz list” and “extended quiz list.” They are different in the parameters they take and in the ways they display the content.
- The simple shortcode displays an extended list of quizzes but does not specify their categories.
- The extended shortcode displays the list of quiz categories that open upon a click to show the quizzes.
Our customer’s WordPress website was in Hebrew. This language has a right-to-left text direction (RTL), which strongly influences the overall looks of pages. This inspired us to add the support for plugin translations.
The plugin was created in English, because it is the traditional language for web development and because the customer did not know Hebrew perfectly.
However, the plugin is translatable into any other language with the help of *.po/*.mo fles popular translation tools. The localization files are stored in the special “languages” folder inside the plugin structure.
This is just a brief description of the custom shortcode embedding plugin that we created for our customer’s WordPress website.
What about your website — do you have ideas to implement or wishes to fulfill? It does not necessarily have to be a WordPress site — our agency works with WordPress, Drupal, and other CMSs. You are welcome to contact our experts!