This section applies if a candidate for an elective office of a city, town, or special purpose district would, under this chapter, otherwise qualify to have his or her name printed on the general election ballot for the office, but the candidate has been declared to be unqualified to hold the office by a court of competent jurisdiction.
(1) In a case in which a primary is conducted for the office:
(a) If ballots for the general election for the office have not been ordered by the county auditor, the candidate who received the third greatest number of votes for the office at the primary shall qualify as a candidate for general election and that candidate's name shall be printed on the ballot for the office in lieu of the name of the disqualified candidate.
(b) If general election ballots for the office have been so ordered, votes cast for the disqualified candidate at the general election for the office shall not be counted for that office.
(2) In a case in which a primary is not conducted for the office:
(a) If ballots for the general election for the office have not been ordered by the county auditor, the name of the disqualified candidate shall not appear on the general election ballot for the office.
(b) If general election ballots for the office have been so ordered, votes cast for the disqualified candidate at the general election for the office shall not be counted for that office.
(3) If the disqualified candidate is the only candidate to have filed for the office during a regular or special filing period for the office, a void in candidacy for the office exists.