• Resolved dendenzilla

    (@dendenzilla)


    Hello,

    Everything was fine until I created this block

    <div class="cat_container primo_cat">
    <?php
        $args = array(
            'post_type' => 'post',
            'posts_per_page' => 6
        );
    
        $post_query = new WP_Query($args);
    
        if($post_query->have_posts() ) {
            while($post_query->have_posts() ) {
                $post_query->the_post();
                ?>
                <?php $color_cat = the_category_ID($echo = false); ?>
                <div class="catalogue_item">
                    <div class="catalogue_item_img">
                        <a href="<?php echo get_permalink(); ?>"><?php the_post_thumbnail('medium'); ?></a>
                    </div>
                    <div class="catalogue_item_txt">
                        <h2><a href="<?php echo get_permalink(); ?>"><?php echo wp_html_excerpt( get_the_title(), 35, '...'); ?></a></h2>
                        <p class="catalogue_excerpt"><?php echo wp_html_excerpt( get_the_excerpt(), 75, '...'.'<a href="'. get_permalink() . '">[lire la suite]</a>');?></p>
                        <p class="catalogue_item_price"> Prix: <?php echo (types_render_field( 'price', array() ));?> € </p>
                    </div>
                    <p class="catalogue_item_cat" style="background-color: <?php  echo get_term_meta( $color_cat, 'cat_color', true ); ?>;">
                        <?php foreach ( ( get_the_category() ) as $category ) {
                            echo $category->cat_name . ' ';
                        }?>
                    </p>
                </div>
                <?php
                }
            }
    ?>
    </div>
    <div class="btn btn-three dark" style="margin: 20px auto;">
        <span>
            <a href="<?php echo get_site_url();?>/catalogue"><?php echo $attributes['bouton-de-la-galerie']; ?></a>
        </span>
    </div>

    Then, it shows correctly on my website but when I try to access the page in the admin i get this:
    There has been a critical error on this website. Please check your site admin email inbox for instructions.

    Is there something wrong in my block or some other way I should be doing this ?

    Thanks

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author nK

    (@nko)

    Hey.

    As I can see, there are 2 strange things in your code:

    1. the_category_ID function is deprecated a long time ago. You need to use get_the_category
    2. What is the function types_render_field? This does not exist in WordPress

    Regards, nK.

    2. types_render_field is used to pull a custom field from the Toolset Types Plugin (which is very similar to Advanced Custom Fields).

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘There has been a critical error on this website.’ is closed to new replies.