Support » Plugin: WPAdverts - Classifieds Plugin » Tweaking the plugin for some misbehaving themes

  • Resolved tamarama

    (@tamarama)


    First of all, thanks for a great plugin.

    This thread is to share my experience resolving my difficulties getting it to work with my customised version of the Striking theme. The plugin works great with the standard WordPress 2016 theme, but I was having issues getting it to work on my setup.

    Context: Installing WPAdverts with the Striking Theme on PHP7 and WP 4.7.1 can in some edge cases (mine) result in the ads not showing their attached graphics.

    Here is how I fixed it. Perhaps this can spare some time for someone else.

    In /wp-content/plugins/wpadverts/includes/functions.php:

    On line 341, the call get_children(array(‘post_parent’=>$id, ‘numberposts’=>1) was failing. By replacing lines 341-341 with the below, I got the function to work for me.

    $attachments = get_children( array(‘numberposts’ => 1,’order’ => ‘ASC’,’post_mime_type’ => ‘image’,’post_parent’ => get_the_ID(),’post_status’ => null,’post_type’ => ‘attachment’) );
    if ( $attachments) {
    foreach ( $attachments as $attachment ) {
    $image = wp_get_attachment_image_src( $attachment->ID, ‘adverts-list’ );
    }
    }

    Then again, on line 1868, this function was failing for me:
    $children = get_children( array( ‘post_parent’ => $post_id ) );

    Replacing it with the following solved the problem for me:

    $children = get_children( array(‘numberposts’ => -1,’order’ => ‘ASC’,’post_mime_type’ => ‘image’,’post_parent’ => $post_id,’post_status’ => null,’post_type’ => ‘attachment’) );

    Cheers,
    -Anders, Sydney

  • The topic ‘Tweaking the plugin for some misbehaving themes’ is closed to new replies.