Error : “Cannot use object of type WP_Post as array in”

Fatal error: Cannot use object of type WP_Post as array in C:\xampp\htdocs\wordpress-4.3.1\wp-includes\query.php on line 3716 I don’t know what is this I am searching from internet but not find the solution Answer This error is telling you that a post object has been passed into a function or method where an array was expected. The … Read more

Error when using setup_postdata()

I am trying to get the most recent and show it using the native function (e.g. get_the_title()), do NOT want to use $post[‘post_title’] but when I do this I’m an error. global $post; $featured_post = wp_get_recent_posts(array( ‘numberposts’=>’1’, ‘post_type’ => ‘post’ )); foreach ($featured_post as $post) { setup_postdata($post); echo get_the_title(); } This is the error I … Read more

Enqueue script multiple times?

I have a script that needs to be enqueued by a shortcode with parameters injected via wp_localize_script. The script is registers in a bootstrapping files then localized and enqueued within the shortcode itself (because it would be too late to register it in the shortcode).. However, wp_enqueue_script only allows each script to be enqueued once, … Read more

Add “data-” attribute to image links

Is it possible to add an attribute and value to image links? I currently have: <a href=”#”> <img class=”img-responsive aligncenter wp-image-1286 size-full” src=”#” alt=”…” width=”858″ height=”304″> </a> and would like to add data-rel=”lightbox-0″ to the link: <a href=”#” data-rel=”lightbox-0″> <img class=”img-responsive aligncenter wp-image-1286 size-full” src=”#” alt=”…” width=”858″ height=”304″> </a> I also need to add the … Read more