• Hi guys I currently have this array, which I had help writing, which switches out the header images for several different categories.

    Now, I need a custom header image for a page instead of a category. It’s just one right now, but it will probably be more later, so I’m thinking I should keep the array format?

    Anyway, here’s the code I currently have and I’d be making

    ‘shop-2’ => ‘headercat14’

    This code is contained within the header.php file:

    <?php
    $c = get_query_var('cat');
    $cat = get_category ($c);
    
    $headers = array(
        'americans-want-peace' => 'headercat01',
        'all-nations-want-peace' => 'headercat02',
        'all-religions-want-peace' => 'headercat03',
        'all-people-want-peace' => 'headercat04',
        'military-america' => 'headercat05',
        'worldwide-warfare' => 'headercat06',
        'persecuting-peacemakers' => 'headercat07',
        'glorifying-war-with-mass-media' => 'headercat08',
        'non-violence-works' => 'headercat09',
        'war-wrecks-usa-economy' => 'headercat10',
    	'united-peace-and-green-movements' => 'headercat11',
    	'save-the-children-social-justice' => 'headercat12',
    	'peace' => 'headercat13',
    	'shop-2' => 'headercat14'
    );
    
    $divid = isset($headers[$cat->slug]) ? $headers[$cat->slug] : 'header';
    
    ?>

The topic ‘modify PHP array for switching out header images’ is closed to new replies.