Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all articles
Browse latest Browse all 8245

deputy963 on "Add shortcodes,text, and htm to a category and its' children"

$
0
0

Hello all,

I would like to add some shortcodes, html, and text to the bottom of all posts in a category and all children of that category(about 15 of 40 categories). The problem is my PHP skills are lacking (to say the least).
example cat 1 <-added to this one
- example cat2 <-added to this one
- example cat3 <-added to this one
-- example cat3a <-added to this one
example cat4 <-NOT added to this one

I figure the best way to accomplish this is to add a filter to the functions.php using something along the lines of

add_filter('the_content', 'custom_category_text');

with a statement like

if (in_cat(28) || post_is_in_descendant_category(28)){$content =  $content . $custom_category_text;
}
return $content;
}

So the whole thing would look something like this:

add_filter('the_content', 'custom_category_text');
function custom_category_text($content){
global $post;
$custom_category_text = 

if (in_cat(28) || post_is_in_descendant_category(28)){$content =  $content . $custom_category_text;
}
return $content;
}

So, does anyone think this will work?

If so, then my question becomes "How do I format the PHP in "$custom_category_text =" so that the shortcodes, html, and text all work?"


Viewing all articles
Browse latest Browse all 8245

Trending Articles