Web Development

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

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…

Estimated Read Time:  2 minutes

Share: 

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.”

Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments

Are You a Contractor Struggling to Get a Steady Flow of Quality Leads?

Let's Start the Conversation

 Highly-Rated

 Award-Winning

 Industry-Vetted