Skip to content
TheChatArchiveThe Chat Archive
Claudeclaude-3-7-sonnet-20250219· AnthropicHugging Face LMArena Human Preference 140K

how to use deffernet 404 page for defferent slug in wordpress

From a Chatbot Arena battleThe same person sent this prompt to two anonymous models at once. Compare it with Claudeclaude-3-5-haiku-20241022’s answer.
  1. User

    how to use deffernet 404 page for defferent slug in wordpress

  2. Claude Assistant

    For WordPress, you can create different 404 pages for different URL slugs by using a custom 404.php template with conditional logic. Here's how:

    1. Create a custom 404.php file in your theme directory
    2. Add conditional statements to check the current URL path
    3. Display different content based on the slug
    <?php get_header(); ?>
    
    <div class="error-page-container">
        <?php
        // Get the current URL path
        $current_url = $_SERVER['REQUEST_URI'];
        
        // Check for specific slugs and display custom content
        if (strpos($current_url, '/products/') !== false) {
            // Product-specific 404 page
            ?>
            <h1>Product Not Found</h1>
            <p>Sorry, the product you're looking for doesn't exist. Browse our <a href="/products/">product catalog</a> instead.</p>
            <?php
        } 
        elseif (strpos($current_url, '/blog/') !== false) {
            // Blog-specific 404 page
            ?>
            <h1>Blog Post Not Found</h1>
            <p>The blog post you're looking for has been moved or deleted. Check out our <a href="/blog/">latest articles</a>.</p>
            <?php
        }
        else {
            // Default 404 page
            ?>
            <h1>Page Not Found</h1>
            <p>Sorry, the page you requested could not be found. Please check the URL or return to our <a href="<?php echo home_url(); ?>">homepage</a>.</p>
            <?php
        }
        ?>
    </div>
    
    <?php get_footer(); ?>
    

    Would you like me to explain or break down this code?

Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.