Submit a enquiry

    Back to all posts

    Using ChatGPT for mundane dev tasks

    by Andrew Tebbott Developer

    Developers often find themselves handling repetitive and time-consuming tasks when working with WordPress or other CMS systems. From formatting HTML code to debugging PHP, these routine chores can slow down productivity. ChatGPT is here to help, automating many of these mundane tasks and allowing developers to focus on more creative and complex aspects of their projects. Here are some practical examples of how ChatGPT can assist with HTML and WordPress development tasks.

    1. Formatting HTML Code

    Properly formatted HTML code is essential for readability and maintenance. Manually formatting code can be tedious. ChatGPT can take your unformatted HTML and clean it up quickly. For instance, if you have a messy HTML snippet:

    <html><body><div><h1>Hello World</h1><p>This is a paragraph.</p></div></body></html>

    You can ask ChatGPT: “Format this HTML code properly,” and it will return:

    <!DOCTYPE html>
            <h1>Hello World</h1>
            <p>This is a paragraph.</p>

    2. Generating HTML Boilerplate

    Creating a basic HTML structure is a routine task for web developers. ChatGPT can generate boilerplate code for you. Simply ask: “Generate a basic HTML5 boilerplate,” and ChatGPT might provide:

    <!DOCTYPE html>
    <html lang="en">
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
            <h1>Welcome to My Website</h1>
            <p>This is a sample page.</p>
            <p>&copy; 2024 My Website</p>

    3. Debugging PHP Code for WordPress

    Debugging PHP code can be challenging, especially when dealing with WordPress themes or plugins. ChatGPT can help identify common errors and suggest fixes. Suppose you have the following PHP code in your WordPress theme:

    function my_theme_scripts() {
    wp_enqueue_style('style', get_stylesheet_uri());
    wp_enqueue_script('script', get_template_directory_uri() . '', array(), '1.0.0', true);
    add_action('wp_enqueue_scripts', 'my_theme_scripts');

    You can ask ChatGPT: “Check this WordPress PHP code for errors,” and it might point out that the dependencies array is missing from wp_enqueue_style:

    function my_theme_scripts() {
        wp_enqueue_style('style', get_stylesheet_uri(), array(), '1.0.0', 'all');
        wp_enqueue_script('script', get_template_directory_uri() . '', array(), '1.0.0', true);
    add_action('wp_enqueue_scripts', 'my_theme_scripts');

    4. Creating Shortcodes in WordPress

    Shortcodes are a powerful feature in WordPress, but creating them can be repetitive. ChatGPT can help you write shortcodes quickly. For example, if you need a shortcode to display the current year, you can ask: “Create a WordPress shortcode to display the current year,” and ChatGPT might provide:

    function current_year_shortcode() {
        return date('Y');
    add_shortcode('current_year', 'current_year_shortcode');

    5. Customising WordPress Loops

    Customising the WordPress loop is a common task, whether you’re modifying how posts are displayed or querying specific content. Suppose you need a custom loop to display the latest 5 posts from a specific category. You can ask ChatGPT: “Write a custom WordPress loop to display the latest 5 posts from a category with ID 3,” and it might generate:

    $custom_query = new WP_Query(array(
        'cat' => 3,
        'posts_per_page' => 5,
    if ($custom_query->have_posts()) :
        while ($custom_query->have_posts()) : $custom_query->the_post(); ?>
            <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
            <p><?php the_excerpt(); ?></p>
        <?php endwhile;
    else : ?>
        <p><?php _e('No posts found.'); ?></p>
    <?php endif; ?>

    ChatGPT is a versatile tool that can significantly reduce the time spent on mundane development tasks in HTML and WordPress. From formatting and debugging code to generating boilerplate structures and custom loops, ChatGPT enhances productivity and allows developers to concentrate on more complex and creative work. Embrace the power of AI in your development workflow, and experience the efficiency boost firsthand 🙂