Articles

WordPress: Conditional Call to Action after a Post Based on Category

date posted

02/16/16

read time

2 Mins

After reading many posts on HubSpot, I was always appreciative that their call to actions at the end of blog posts were specific to what I just read. When I finished a post about social media, there would be a call to action: “Enter your e-mail now, for a free download of ’99 quick tips for skyrocketing your social media engagement’ or if I finished a post about WordPress there would be a call to action: “Sign up now to get a WordPress Snippet a day for better development.”

So this has all kinds of applications –

Figure out what makes sense for your situation

Getting specific is important – so for you marketing minded people who code – you can use this WordPress snippet to create a conditional call to action after a post based on the category of the post the visitor is reading.


<?php if (in_category('marketing')) ?>
<img src="http://placehold.it/650x350?text=Marketing+Blog+Call+To+Action">
<?php elseif (in_category('web-design')) : ?>
<img src="http://placehold.it/650x350?text=Web+Design+Call+To+Action">
<?php elseif (in_category('web-development')) : ?>
<img src="http://placehold.it/650x350?text=Web+Development+To+Action">
<?php else : ?>
<?php endif; ?>

An example of this is right below for my WordPress development category. Since this post is in that category, I am showing a call to action for my forthcoming e-book “WordPress Development for Noobs.”

Learn How To Do Google Local Service Ads Yourself (Free DIY Course)

Want to know how to start getting Local Service Ads leads on your own?

🎥 3 original videos designed to help you get started on LSA Ads.

🔥 Get the ‘Google Guaranteed’ badge to use in other marketing as well.

📈 Only pay per lead, and start getting more leads soon!

Is there you or someone on your team that would like to take it? Enter their info (or yours) below!

Ready to take the leap?

“We know what it takes to help get home service businesses more leads with Google. Even if we’re not the right fit, we’ll get you where you need to go.”

A woman with long, wavy brown hair stands confidently in front of a black brick wall, embodying Tim Brown's iconic urban style. She wears a black top and accessorizes with a heart pendant gold necklace.
- Sydnee Olsen, Sales Lead
Schedule Intro Call Schedule a Free 20-Minute Consultation (No Obligation)