1

I have made a huge mistake. I wrote a long code inside only one php tag and now when I have to format it with a .css it makes me a huge pain to develop. I tried to convert it to php tags but I always get HTTP 500 error.

<?php
    $args = array('post_type' => 'menu', 'posts_per_page' => 5, 'post__in'  => $ids, 'post_status' => 'any', 'orderby' => 'post__in');
    $query = new WP_Query( $args );
        if ( $query->have_posts() ) {
            while ( $query->have_posts() ) {
                    $query->the_post();
                      if (is_page(538) ) {
                        echo get_the_title();
                        $levesek = get_field('levesek');
                        $leves_adag = get_field('leves_adag');
                        echo "<br>Levesek:<br>";
                       if($levesek) {
                            foreach ($levesek as $leves) {
                                setup_postdata($leves);
                                    echo get_the_post_thumbnail( $leves->ID ) ."<br>";
                            }
                        }
                        wp_reset_postdata();
        ?>
1
  • you are missing the three curly brackets in before wp_reset_postdata(). Dec 22, 2017 at 12:09

1 Answer 1

2

you are missing the three curly brackets in before wp_reset_postdata().

backup your code and replace with this.

<?php
$args = array('post_type' => 'menu', 'posts_per_page' => 5, 'post__in'  => $ids, 'post_status' => 'any', 'orderby' => 'post__in');

$query = new WP_Query( $args );
if ( $query->have_posts() ) {
    while ( $query->have_posts() ) {
        $query->the_post();
        if (is_page(538) ) {
            echo get_the_title();
            $levesek = get_field('levesek');
            $leves_adag = get_field('leves_adag');
            echo "<br>Levesek:<br>";
            if($levesek) {
                foreach ($levesek as $leves) {
                    setup_postdata($leves);
                        echo get_the_post_thumbnail( $leves->ID ) ."<br>";
                }
            }
        }
    }
}
wp_reset_postdata();
?>
1
  • 1
    It's okay, I fixed it, my problem is to convert this whole think to <?php tags Like <?php echo "Text" ?>
    – DeluxeD
    Dec 22, 2017 at 12:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.