Wordpress Categories: Trying to get property of non-object

蓝咒 提交于 2020-01-07 03:07:27

问题


I'm new to Wordpress. I'm getting this error:

Notice: Trying to get property of non-object in /mnt/stor10-wc1-ord1/825767/iucn.oceanic.net.fj/web/content/wp-content/plugins/super-socializer/super_socializer.php on line 486

This is caused by a plugin I'm using "Super Socializer". It works great with other pages but I have created a custom post type and have 3 categories. A link takes it to a category template. Eg: link a shows posts with category A, link B shows posts with category B etc,

My category Temp code is sth like this:

       <?php

                $args = array(
                    'posts_per_page' => 10,
                    'post_status' => 'publish',
                    'post_type' => 'oursuppliers',
                    'cat' => 35
                );
                query_posts($args);

                ?>



                <?php
                if ( have_posts() ): while ( have_posts() ) : the_post();
                    $post_title = get_the_title();
                    $post_author = $post->post_author;
                    $post_date = $post->post_date;
                    $link = get_field("resource-uploader");
                    $post_thumbnail_id = get_post_thumbnail_id( $id );
                    $thumbnail = wp_get_attachment_image_src( $post_thumbnail_id, "thumbnail");
                    $thumbnail = $thumbnail[0];
                    if( empty($thumbnail) ){
                        $thumbnail = get_template_directory_uri() . "/resources/images/default-150x150.jpg";
                    }
                    ?>
                    <div >
                        <ul style="list-style: none; ">
                            <li style="display: inline; margin: 3%; height: 350px; " class="col-md-3">
                                <div>
                                    <h5 style="font-weight: bold; color: #003399"><?php the_title() ?></h5>
                                </div>
                                <div>
                                    <a href="<?php the_permalink(); ?>">  <img style="width: 150px; height: 150px; align-content: center;"  src="<?php echo get_field("supplier_logo") ?>"/></a>
                                </div>

                            </li>
                        </ul>

                    </div>
                <?php endwhile; endif; wp_reset_query(); ?>
            </div>

Could anyone guide me on how I might b able to remove that error. I don't need the share plugin on this template anyways...

Thank you in advance :)


回答1:


Most of the time, Wordpress's notices are something that you don't have to worry at all, although it's a good idea to inform the plugin's developers so they can fix it in future versions.

If your site works correctly and you are managing a productive site, the best approach should be turning off debug messages.

In your wp-config.php file, set WP_DEBUG to false:

define('WP_DEBUG', false);



来源:https://stackoverflow.com/questions/33468518/wordpress-categories-trying-to-get-property-of-non-object

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!