Adding an CTA button shortcode on wordpress
Follow the steps below to edit your Theme setting file to add a customised CTA button using shortcode:- Log in to your WordPress site with an administrator account.
-
On the Dashboard in the left sidebar, click Appearance, and then click Theme Editor:
🚧 Important You will not be able to roll back to your earlier Theme configuration after any edits. Save the Theme files before proceeding with the modifications.
-
On the Theme Editor, select the Theme you want to edit from the dropdown:
-
The files for this selected theme are listed on the right column under Theme Files. Click on the file named “functions.php”:
- Insert the following code to the end offunctions.php file.
- link: default link to redirect users to once the button is clicked
- label: label of the button
- target: Where the page should be displayed
- $output stores the HTML code of the button element
- Open the blog post or page and add the CTA button shortcode [cta_button]:
-
The CTA button displayed on the bottom of a page:
-
Right click on the CTA button to inspect the HTML code for the button: