Urgent help needed with php code

Hi,

I have been tasked with “fixing” a site that the builders of the site have just left. I’m a photographer thata dabbles in web design and have little php knowledge. the problem is with the sidebar menu. It’s made from products/posts in categories that are supposed to show up (and drop down) when clicked on but only one ever does. I’ve tried to check the code but I’m afraid I can’t make head or tail as to where the problem is. Any takers on getting this to work?

The site is: seasystems.se

The code for single-product.php is

<?php get_header(); ?>

<div class="default-page products row">
    <div id="sidebar-toggle">SHOW OTHER PRODUCTS >></div>
    <div class="sidebar large-3 columns">

        <?php while (have_posts()) : the_post(); ?>
            <?php
            $product_category = get_the_category(get_the_id());
            $product_category = $product_category[0]->term_id;
            ?>
        <?php endwhile; ?>

        <?php
        $cat_arr = [];
        $cat_ids = [];

        $prod_terms = get_terms('category', array('exclude' => array('1')));

        foreach ($prod_terms as $prod_term) {
            $cat_arr[] = array('post_type' => 'products', 'cat' => ''.$prod_term->term_id.'');
            $cat_ids[] = $prod_term->term_id;
        }
        ?>

        <ul>
            <?php for ($i = 0; $i < count($cat_ids); $i++) : ?>
                <?php $prod = new WP_Query($cat_arr[$i]); ?>

                <li <?php if ($product_category != $cat_ids[$i]) echo 'class="inactive-menu"'; ?>>
                    <a href="#" class="category-name"><?php echo get_cat_name($cat_ids[$i]); ?></a>
                    <ul class="single-product" <?php if ($product_category != $cat_ids[$i]) echo 'style="display:none"'; ?>>
                        <?php while ( $prod->have_posts() ) : $prod->the_post(); ?>
                            <li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
                        <?php endwhile; ?>
                    </ul>
                </li>
            <?php endfor; ?>

        </ul>
    </div>

    <div class="column-content product large-9 columns">
        <?php while (have_posts()) : the_post(); ?>
            <h1 class="title">
                <?php the_title(); ?>
            </h1>

            <div class="content">
                <?php the_content(); ?>
            </div>
        <?php endwhile; ?>

        <?php if (get_field('data_sheet_download') OR get_field('system_download') OR get_field('approvals_download')) : ?>
        <div class="downloads">
            <h2 class="title">Downloads</h2>

            <ul>
                <?php if (get_field('data_sheet_download')) : $field = get_field('data_sheet_download'); ?>
                    <li><a href="<?php echo $field['url'] ?>" target="_blank">DATA SHEET: <strong><?php echo $field['title'] ?></strong></a></li>
                <?php endif; ?>
                <?php if (get_field('system_download')) : $field = get_field('system_download'); ?>
                    <li><a href="<?php echo $field['url'] ?>" target="_blank">SYSTEM: <strong><?php echo $field['title'] ?></strong></a></li>
                <?php endif; ?>
                <?php if (get_field('approvals_download')) : $field = get_field('approvals_download'); ?>
                    <li><a href="<?php echo $field['url'] ?>" target="_blank">APPROVALS: <strong><?php echo $field['title'] ?></strong></a></li>
                <?php endif; ?>
            </ul>
        </div>
        <?php endif; ?>
    </div>
</div>

<?php get_footer(); ?>

Thanks a lot in advance!

Cheers
/Ola

Hi Ola, I’m pretty new to PHP but have built several websites using WordPress.

I can take a look if you want?

Hi,

Absolutely, I’ve built a fair share of Wordpress sites myself but I’ve never really learnt php. I’ll set up a guest login for you but it will have to be after the weekend.

Cheers
Ola

Sponsor our Newsletter | Privacy Policy | Terms of Service