in shulchan aruch orach chayim 98:1 the Rama writes וְאָסוּר לְאָדָם לְנַשֵּׁק בָּנָיו הַקְּטַנִּים בְּבֵית הַכְּנֶסֶת, כְּדֵי לִקְבֹּעַ בְּלִבּוֹ שֶׁאֵין אַהֲבָה כְּאַהֲבַת הַמָּקוֹם בָּרוּךְ הוּא (בִּנְיָמִין זְאֵב סי' קס''ג וַאֲגֻדָּה פ' כֵּיצַד מְבָרְכִין). i am wondering if any contemporary authorities deal with this issue. in my experience this psak is not practiced in many communities.
Rav Ari Enkin discusses both sides of the questions, but to see sources who allow it:
Nevertheless, it is permitted to kiss one's child in the synagogue if necessary in order to calm him down after getting hurt, or the like.[Rivevot Ephraim 2:61, Veharev Na;Shemot, Aleinu Leshabeiach p.579] One is also permitted to kiss one's child in order to make the child feel important, encouraged, or as praise for something positive the child has done, such as asking or answering a sharp Torah question.[Veharev Na;Shemot] This is similar to the custom of the Talmudic sages who would kiss one who has delivered an impressive Torah discourse. This was practiced both in the synagogue and even in the Beit Hamikdash.[Avot D'rabbi Natan 6, Nedarim 96, Kalla 1:21. See Piskei Teshuvot 98 note 70]
Finally, there is a view among some halachic authorities that the prohibition against kissing one's children in the synagogue applies only while services are being conducted, but is permissible at all other times.[Piskei Teshuvot 98:7] This innovative ruling is based on the observation that the halacha which forbids kissing in the synagogue is codified in the Shulchan Aruch under "The Laws of Prayer" and not under "The Laws of the Synagogue".