WordPress.org

Forums

YOP Poll
[resolved] Archive Page - Before Start Date (4 posts)

  1. J Reswob
    Member
    Posted 1 year ago #

    Problem:
    Even though I have cleared everything out of the Before Start Date template, the archive page still accounts for these. So if I have 5 polls scheduled and 5 per page to display I get nothing on the first page of archives. If you inspect the page you will see the 5 or so entries.
    To summarize:
    I want the archive page to bypass both displaying or querying schedules polls. I was planning on having multiple scheduled polls and want the archive page to only display past polls.

    Is there a way or can you tell me what line of code to edit.

    Thanks

    http://wordpress.org/plugins/yop-poll/

  2. YOP
    Member
    Plugin Author

    Posted 1 year ago #

    Hi J Reswob,

    Please edit inc/yop_poll_model.php and replace

    public static function get_archive_polls( $orderby = 'archive_order', $order = 'asc', $offset = 0, $per_page = 99999 ) {
    global $wpdb;
    $archive = $wpdb->get_results(
    $wpdb->prepare(
    "
    SELECT id
    FROM ".$wpdb->yop_polls."
    WHERE
    show_in_archive = 'yes'
    ORDER BY " . esc_attr( $orderby ) . " " . esc_attr( $order ) . "
    LIMIT %d, %d
    ",
    $offset,
    $per_page
    ),
    ARRAY_A );
    return $archive;
    }

    with

    public static function get_archive_polls( $orderby = 'archive_order', $order = 'asc', $offset = 0, $per_page = 99999 ) {
    global $wpdb;
    $archive = $wpdb->get_results(
    $wpdb->prepare(
    "
    SELECT id
    FROM ".$wpdb->yop_polls."
    WHERE
    show_in_archive = 'yes' AND
    end_date <= %s
    ORDER BY " . esc_attr( $orderby ) . " " . esc_attr( $order ) . "
    LIMIT %d, %d
    ",
    self::get_mysql_curent_date(),
    $offset,
    $per_page
    ),
    ARRAY_A );
    return $archive;
    }

    This way, only the polls that have the end date prior to the current server date will be displayed on the archive page.

    Best wishes,

    YOP Team

  3. J Reswob
    Member
    Posted 1 year ago #

    Thank you for quick reply and fix! It worked perfect. Appreciate the great plugin.

    Requested features:
    When selecting start or end date...would like this to default to current date without have to click now.

    When displaying all polls in control panel...would like this do default to show them in ascending order so it always show the last poll you entered instead of the first one.

    Thanks again!!

  4. YOP
    Member
    Plugin Author

    Posted 1 year ago #

    Hey J Reswob,

    We will take your suggestions into consideration and try to implement them in the future.

    If you like our plugin and find it useful, we could use a review.

    Regards,

    YOP Team

Topic Closed

This topic has been closed to new replies.

About this Plugin

About this Topic