Quantcast
Channel: Syntax for conditional statement in Wordpress functions.php - Stack Overflow
Viewing all articles
Browse latest Browse all 3

Syntax for conditional statement in Wordpress functions.php

$
0
0

My knowledge is extremely limited but I've managed to add a filter in a custom functions.php file to display some custom field shortcodes before Post content:

//Insert custom event fields at the beginning of post content    function custom_event($content) {    $beforecontent = '<strong>[acf field="date"] [acf field="time"] [acf field="location" ] </strong>';    $fullcontent = $beforecontent . $content;    return $fullcontent;}add_filter('the_content', 'custom_event');

Can anyone please help me with the correct syntax if I want to make this conditional on the Post being in a specific category? I think I can use the in_category( 'x' ) function, I'm just not sure of the syntax. I ultimately want to add some text between the variables so it will display

On [date] at [time] at [location]

for posts in the 'Events' category.

Thanks in anticipation.


Viewing all articles
Browse latest Browse all 3

Latest Images

Trending Articles





Latest Images