Estimated Reading Time: 2 min
To add a Facebook Like button to your mobile WordPress posts and ensure it is responsive, follow these steps:
Step 1: Create a Facebook App
- Go to the Facebook for Developers site and create a new app to obtain your App ID.
Step 2: Get the Facebook Like Button Code
- Visit the Facebook Like Button documentation.
- Customize the button and generate the code snippet.
Step 3: Add the Code to Your WordPress Theme
- Go to your WordPress admin dashboard.
- Navigate to Appearance > Theme Editor.
- Locate the
single.php
file (orcontent.php
based on your theme). - Insert the generated Facebook Like button code where you want it to appear, like this:
html ¨K7K
Step 4: Include the Facebook SDK
- Before the closing
</body>
tag in yourfooter.php
file, add:html ¨K8K ¨K9K
Step 5: Write Responsive Design CSS
To make the Facebook Like button responsive, you can add some custom CSS. Here’s an example:
Go to Appearance > Customize.
Select Additional CSS.
Add the following CSS code:
.fb-like { width: 100% !important; /* Make the button take the full width */ max-width: 450px; /* Set a max-width to maintain layout */ margin: 0 auto; /* Center the button */ } /* Adjust the button's size on smaller screens */ @media (max-width: 600px) { .fb-like { max-width: 100%; /* Allow full width on mobile */ } }
Step 6: Test the Implementation

- Open a post on your mobile device or in a mobile view emulator to check if the Facebook Like button appears correctly and is responsive.
By following these steps, you should successfully add a responsive Facebook Like button to your mobile WordPress posts.