How to knit a button loop?
Option 1: yarn over (small circle)
A yarn over generally works well. Do remember to reduce afterwards, so your stitch count stays the same. In your example that would be:

k13, yo, k2tog, k12

Knit the next row normally. Treat the yarn over as if it was a normal stitch.
Option 2: double yarn over (larger circle)
If you want a bigger buttonhole, it is possible to use a double yarn over. Remember to decrease on both sides in this case, so your stitch count remains the same. Use ssk for a left leaning decrease and k2tog for a right leaning one.

k12, ssk, yo, yo, k2tog, k11

Knit the next row normally, except the two yarn overs. You have two options for handling this one:

You can knit one and purl the other.

You can slip the first yarn over off the needle, so you only have one left. Then you knit that stitch through both the front and the back.


Option 3: bind off and cast on (long)
Alternatively, you can make a long buttonhole. The top two options are a bit easier and are generally sufficient, but it's good to know a long buttonhole is possible too.
With the right side of your work facing you, you bind off a couple stitches. On the next row you cast them on again. For example (assuming flat stockinette):

Row 1 (right side): k10, bind off 7, k10
Row 2 (wrong side): p10, cast on 7, p10

You can use your favourite method to cast on the stitches on row 2 that works in the middle of a row, for example one of these.
I am not affiliated with either of the linked blogs. I simply believe they offer good explanation of the techniques. If they exist, or exist in the future, feel free to replace them with links to questions on this network instead.