Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've created custom PHP code which allows for user input from two dropdowns and queries a database to return listings which are displayed on a page. The PHP code works fine as a standalone: Here. The problem comes when I add it to a custom Wordpress template.

The code breaks the template formatting and ends up looking like this. Notice the second dropdown and the confirm button are gone.

I've narrowed the problem down to a PHP echo statement that returns the choices for the first dropdown. Though I can't figure out why it's causing the problem. I'm happy to provide more details if needed. thanks! The code for the custom template is below.

<?php
/*
Template Name: Jobs Child Page of Parent 2
*/

get_header(); 
the_post();
?>

<?php
if (isset($_GET['cat']))
{
$cat = $_GET['cat'];
}
else
{
$cat = "0";
}
if (isset($_GET['type']))
{
$sub = $_GET['type'];
}
else
{
$sub = "0";
}
?>

    <div id="primary" class="inner-page inner-page-parent">

        <div id="inner-left">
            <div id="breadcrumbs">
                <div class="breadcrumbs">
                  <?php if(function_exists('bcn_display'))
                  {
                       bcn_display();
                  }?>
                </div>
            </div>
                <div id="inner-page-title-block">

                <div id="inner-page-title-block-right">
                    <?php echo   get_the_post_thumbnail($post->ID, "excerpt-thumb"); ?>
                </div>
            </div>
            <div id="inner-content">
            <?php
        $page_id = get_the_ID();
        if($page_id==2){ ?> <h3>About Us — A Picture of Pinnacle</h3><p></p> <?php }else {?> 
                    <h3><?php the_title(); ?></h3> <p></p>
                     <?php  } ?>    

            <?php the_content(); ?>

         <html>
<head>

    <link rel="stylesheet" href="/joblisting/styles.css" type="text/css" />

     <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <!--<script src="jquery.min.js"></script>-->
    <script type="text/javascript">
        $(document).ready(function(){
            //  $("select#type").attr("disabled","disabled");
            $("select#category").change(function(){
                $("select#type").attr("disabled","disabled");
                $("select#type").html("<option>wait...</option>");

                var id = $("select#category option:selected").attr('value');

                $.post("select_type.php", {id:id}, function(data){
                    $("select#type").removeAttr("disabled");
                    $("select#type").html(data);
                });
            });

            $("form#select_form").submit(function(){
                // Fetch values and parse them to integers
                var cat = parseInt( $("#category").val(), 10 );
                var type =  $("#type").val();


                if(cat>0 && type>0)
                {
                    $.ajax({
                        type:'GET',
                        url:'/joblisting/display.php',
                        data:'cat='+cat+'&type='+type,
                        success:function(data)
                        {
                            $("#result2").html("");
                            $("#result2").html(data);
                        }
                    });

                }
                else
                {
                    $("#result2").html("you must choose two options!");
                }
                return false;
            });
        });
    </script>
</head>

<body style="background:#DADADA;color:#000000;">
    <?php include "/joblisting/select.class.php"; ?>
    <div>
        <form id="select_form" action="">
            <div style="border:1px solid #347F82; padding:20px;text-align:left;">
                <table>
                    <tr><td><b>Choose a category:</b></td>
                        <td>
                            <select id="category" name="category" class="wrapper-dropdown">
                            <?php echo $opt->ShowCategory($cat); ?>
                            </select>
                        </td>
                    </tr>
                    <tr><td><b>Choose a type:</b></td>
                        <td>
                            <select id="type" name="type" class="wrapper-dropdown">
                                <option value="0">choose...</option>
                               <?php
                                if ($sub != "0")
                                {
                                    echo $opt->ShowType($cat, $sub);
                                }
                                ?> 
                            </select>
                        </td>
                    </tr>
                    <tr><td colspan="2">&nbsp;</td></tr>
                    <tr align="center"><td colspan="2">
                        <input type="submit" value="Confirm" class="classname" />
                    </td></tr>
                </table>

            </div>
        </form>
        <?php include "/joblisting/display.php"; ?>

        <div id="result2"></div>
    </div>
</body>
</html>         


<?php
if($post->post_parent) {
$parent = get_post($post->post_parent);


        if($page_id=2){ ?>  <?php }else {?> 

<?php 
echo get_the_title($post->post_parent); } 
?></p>

<?php } ?>


<?php
                $children =& get_children( 'post_type=page& post_parent='.$post->post_parent );
                foreach($children as $child){
                    ?>




<div class="inner-child-blocks">                            


                    </div>





        <?php } ?>


<div style="clear:both;"></div>
            </div>



            </div>
        </div>
        <div id="inner-right">
            <?php if(!dynamic_sidebar("home-widget-column-1")){?>

                <div id="swboc-5" class="widget SWBOC_Widget"><div class="widget-title-wrapper"><h2 class="widget-title">Featured Practice Opportunity</h2></div><p><img class="alignnone size-medium wp-image-74" title="sample-2" src="<?php echo bloginfo("template_url"); ?>/images/sample-2-283x185.jpg" alt="" width="283" height="185"></p>
                    <p>Quisque in libero ipsum, ut dictum sem. Cras ac ornare purus. Etiam sapien mauris, suscipit at aliquet vel, vestibulum id tortor. Donec porta porta orci ut pharetra. Sed risus nunc, condimentum at ultricies quis, ultrices sed felis. Vivamus ac eros vitae lacus convallis dapibus. Nunc ullamcorper sodales sapien ut consequat. Ut elit leo, iaculis vel tempus nec, feugiat ac est.<br>
                    <a href="#">READ MORE</a></p>
                    <div style="clear: both;"></div>
                </div>  

                <?php } ?>
            <?php if(!dynamic_sidebar("home-widget-column-2")){ ?>

                <div id="text-6" class="widget widget_text">
                    <div class="widget-title-wrapper"><h2 class="widget-title">Search for Job Opportunities</h2></div>          
                    <div class="textwidget">
                        <form>
                            <div><select><option>Select your profession...</option></select></div>
                            <div><select><option>Select your specialty...</option></select></div>
                            <div><select><option>Select your location...</option></select></div>
                            <div><input type="submit" value="SEARCH JOB"/></div>
                        </form>
                    </div>
                    <div style="clear: both;"></div>
                </div>


                <?php } ?>  
            <?php if(!dynamic_sidebar("home-widget-column-3")){ ?>
                    <div id="advanced-recent-posts-2" class="widget advanced_recent_posts_widget"><div class="widget-title-wrapper"><h2 class="widget-title">Articles, News, Press and Announcements</h2></div>
                        <ul>
                            <li class="recent-post-item first-child">
                                <p class="post-date">December 09, 2012, Sunday</p>
                                <a href="http://test.jkdevices.com/wordpress/?p=41" rel="bookmark" title="Permanent link to A wordpress post #3" class="post-title">A wordpress post #3</a>
                                <div class="post-entry">
                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus pellentesque felis ut neque vestibulum eu  <a href="http://test.jkdevices.com/wordpress/?p=41" class="more-link">Read more</a> </p>
                                </div>
                            </li>
                            <li class="recent-post-item">
                                <p class="post-date">December 09, 2012, Sunday</p>
                                <a href="http://test.jkdevices.com/wordpress/?p=39" rel="bookmark" title="Permanent link to A wordpress post #2" class="post-title">A wordpress post #2</a>
                                <div class="post-entry">
                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec ac urna blandit nisi egestas gravida  <a href="http://test.jkdevices.com/wordpress/?p=39" class="more-link">Read more</a> </p>
                                </div>
                            </li>
                            <li class="recent-post-item last-child">
                                <p class="post-date">December 09, 2012, Sunday</p>
                                <a href="http://test.jkdevices.com/wordpress/?p=37" rel="bookmark" title="Permanent link to A wordpress post #1" class="post-title">A wordpress post #1</a>
                                <div class="post-entry">
                                    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Donec pellentesque, odio et molestie scelerisque, tellus  <a href="http://test.jkdevices.com/wordpress/?p=37" class="more-link">Read more</a> </p>
                                </div>
                            </li>
                        </ul>
                        <div style="clear: both;"></div>
                    </div>
                <?php } ?>
        </div>
        <div style="clear: both;"></div>
    </div><!-- #primary -->

<?php get_footer(); ?>
share|improve this question
    
Did you try to enable logging and check what's in the logs? –  dalbaeb Mar 8 '13 at 21:03
    
Actually it's easy: your $opt variable is not defined anywhere in your code. –  dalbaeb Mar 8 '13 at 21:05

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.