I see these 2 terms (sloka and mantra) being used interchangeably. But they are not the same. If someone knowledgeable can elaborate on the difference for the benefit of the future users, it would be very insightful.
A Sloka is referred to mean a verse of two lines, of sixteen syllables each, ie. written in the Anushtubh metre... An example of a Sloka would be:
Sarasvati namastubhyam varadē kāmarūpiṇi| Vidyārambham kariṣyāmi siddhirbhavatu mē sadā||
A Mantra, on the other hand, is a longer prayer, usually composed of many Slokas. It is also called Stotra... An example of a Mantra would be Shiva Tandava Stotram
I am going to attempt at answering this based on study I did.
A Shloka (or Sloka) basically seems to be a poetic meter, consisting of varying number of syllables or lines, 2 lines of 16 syllables or 4 lines of 8 syllables. Both the itihasas, Ramayana and Mahabharata are primarily written Shloka format.
The word Mantra's root is explained as "Manah trayate iti mantrah" or "mananat trayate iti mantraha". I have seen 2 different explanations for this. One that should/does keep coming back to the mind (OR) one that liberates the mind.
What I have heard from my teachers is the definition that says "Mantra is that which liberates the mind". We can add to it, "through constant remembrance/usage/prayoga". It doesn't seem to have any rules regarding number of syllables or lines. But certain mantras are not to be uttered/ utilized unless it has been handed down by a proper Guru.