Search code examples
phpwordpressiframelocalhostlive

Query work in localhost, but not in live


I need to make iframe url, for example:

https://url.com/category/{category_name)/t=desktop || /t=mobile.

I'm using MAMP to run my local dev env and i got it working like it should be, when query string is equal to desktop it shows 3 posts and when mobile then only one post. Now the issue is following, when sysadmin is updating pre-live env he can see from logs this error:

[Wed Nov 15 20:09:42.122140 2017] [:error] [pid 7776] [client 10.1.2.66:41696] PHP Parse error: syntax error, unexpected end of file, expecting elseif (T_ELSEIF) or else (T_ELSE) or endif (T_ENDIF) in /var/lib/wordpress/wp-content/themes/wpTheme2/single_iframe.php on line 234

single-iframe.php full code: https://pastebin.com/MBC6thDW

When i'm trying to go test url i'm either getting Error 500 or header with query function just printed out.

I'm using PhpStorm IDE and it doesn't show any errors in my code, what i'm missing here?


Solution

  • Try this code

    https://pastebin.com/7ubTY2A4

    <?php
    if ( ! defined( 'ABSPATH' ) ) {
        exit;
    }
    ?>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
        <meta name="description" content="<?php bloginfo('description'); ?>">
        <?php
        if(get_field('fav_icon', 'option') != ''){
            $favId = get_field('fav_icon', 'option');
            $favDetails = wp_get_attachment_image_src($favId, 'full');
        }
        ?>
        <?php if(!empty($favDetails)): ?>
          <link rel="shortcut icon" href="<?php echo $favDetails[0]; ?>">
        <?php endif;?>
    
    
    
    
        <title><?php wp_title();?></title>
    
    
        <link href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet" integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN" crossorigin="anonymous">
    
    
        <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
        <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
        <!--[if lt IE 9]>
        <script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
        <script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
        <![endif]-->
        <?php wp_head(); ?>
        <!--[if (lt IE 9)&(!IEMobile)]>
        <link rel="stylesheet" type="text/css" href="enhanced.css" />
        <link rel="stylesheet" type="text/css" href="iframe.css" />
        <![endif]-->
        <?php
        if(is_front_page()){
            $info = get_bloginfo('description');
    
            echo '<meta name="og:description" content="'.$info.'">';
            echo '<meta name="og:title" content="Website">';
        }
        ?>
        <style>
            .main-header--frame {
                background-color: #a40057;
                margin-bottom: -40px;
            }
            .main-header--frame .categoryTitle {
                display: inline-block;
                padding-top: 19px;
                padding-left: 10px;
                color: #ffffff;
            }
    
            .main-header.main-header--frame .container {
                max-width: 1200px;
                background-color: transparent;
            }
    
        </style>
    
    </head>
    <body>
    <header class="main-header main-header--frame">
        <nav>
            <div class="container">
                <div class="navbar-header">
                    <a href="https://stiil.ee" class="navbar-brand">
                        <img src="logo" alt="logo"
                             class="img-responsive">
                    </a>
                    <h1 class="categoryTitle">Description</h1>
                </div>
            </div>
        </nav>
    </header>
    <main class="main-content main-content-inner valitud-content-inner">
        <div class="container">
                <?php
                $queried_object = get_queried_object();
                $taxChilds = get_terms( array(
                        'taxonomy' => 'category',
                        'hide_empty' => true,
                        'child_of' => $queried_object->term_id
                ) ); ?>
    
                <?php if(isset($_GET) && $_GET['t'] == 'desktop'): ?>
                  <div class="category-wrap">
                                <?php
                                $queried_object = get_queried_object();
                                $count =0; 
                                foreach($taxChilds as $taxChild): ?>
                                    <?php
                                    $args = array(
                                            'post_type'=> 'post',
                                            'cat' => $taxChild->slug,
                                            'posts_per_page' => '1',
                                            'orderby' => 'rand',
    
                                            'tax_query' => array(
                                                    array(
                                                            'taxonomy' => 'category',
                                                            'field'    => 'term_id',
                                                            'hide_empty' => false,
                                                            'terms'    =>  $taxChild->term_id,
                                                    ),
                                            )
                                    );
                                    query_posts($args); if(have_posts()):
                                        while(have_posts()): the_post(); ?>
                                            <div class="col-md-4 all itemz <?php echo $taxChild->slug; ?>" data-cat="<?php echo $taxChild->slug; ?>">
                                                <div class="item-wrap">
                                                    <a href="<?php the_permalink();?>"><?php the_post_thumbnail('size-370x416');
                                                                                    $sponsored = get_field('is_sponsored_content');
                                                                                    if($sponsored){
                                                                                        echo '<div class="sponsored-text">Ad</div>';
                                                                                    };
                                                                                    ?></a>
                                                    <div class="overlay">
                                                        <div class="notify">
                                                            <a href="<?php the_permalink(); ?>"><img src="<?php echo get_post_cat_img_src();?>" alt=""></a>
                                                        </div>
                                                        <h2  class="categoryTitle"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                                                    </div>
                                                </div>
                                            </div>
                                        <?php endwhile; 
    
                                    endif; wp_reset_query();?>
                                    <?php
                                    if ($count == 2) {
                                        break;
                                    }
                                    ?>
                                    <?php $count++; endforeach;?>
                  </div>
                <?php endif; ?>
    
                <?php if(isset($_GET) && $_GET['t'] == 'mobile'): ?>
                  <div class="category-wrap">
                                <?php
                                $queried_object = get_queried_object();
                                $count =0;  foreach($taxChilds as $taxChild): ?>
                                    <?php
                                    $args = array(
                                            'post_type'=> 'post',
                                            'cat' => $taxChild->slug,
                                            'posts_per_page' => '1',
                                            'orderby' => 'rand',
    
                                            'tax_query' => array(
                                                    array(
                                                            'taxonomy' => 'category',
                                                            'field'    => 'term_id',
                                                            'hide_empty' => false,
                                                            'terms'    =>  $taxChild->term_id,
                                                    ),
                                            )
                                    );
                                    query_posts($args); 
                                    if(have_posts()): 
                                        while(have_posts()): the_post(); ?>
                                    <div class="col-md-4 all itemz <?php echo $taxChild->slug; ?>" data-cat="<?php echo $taxChild->slug; ?>">
                                        <div class="item-wrap">
                                            <a href="<?php the_permalink();?>"><?php the_post_thumbnail('size-370x416');
                                                                            $sponsored = get_field('is_sponsored_content');
                                                                            if($sponsored){
                                                                                echo '<div class="sponsored-text">SISUTURUNDUS</div>';
                                                                            };
                                                                            ?></a>
                                            <div class="overlay">
                                                <div class="notify">
                                                    <a href="<?php the_permalink(); ?>"><img src="<?php echo get_post_cat_img_src();?>" alt=""></a>
                                                </div>
                                                <h2  class="categoryTitle"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
                                            </div>
                                        </div>
                                    </div>
                                    <?php endwhile; 
                                    endif; wp_reset_query();?>
                                    <?php
                                    if ($count == 0) {
                                        break;
                                    }
                                    ?>
                                    <?php $count++; endforeach;?>
                  </div>
                <?php endif; ?>
    
        </div>
    </main>
    </body>
    
    <!--main-content ends-->
    <?php wp_footer(); ?>