Shortcodes offer a great flexibility for including plugins in your content on a certain position, but during the repositioning of the ad blocks using the shortcodes, provided by the adrotate plugin, I got confronted with the following problem:
Is it possible to use shortcodes in the content before the occurence of the more – tag such that it gets handled as intended in the “full view” of the posting but is hidden in the index of the front page?
In my case it was important to hide the ad blocks on the front page, otherwise each excerpt in the index would contain an ad which is not acceptable.
Solution
Add one of the following code snippets to the functions.php of your theme
- Remove all shortcodes from the content
function remove_shortcode_from_index($content) { if ( is_home() ) { $content = strip_shortcodes($content); } return $content; } add_filter('the_content', 'remove_shortcode_from_index'); - Remove an specific shortcode (e.g. adrotate)
function dummy_adrotate_shortcode($atts) { return ""; } //remove shortcode from content function remove_shortcode_from_index($content) { //check for front page if (is_home()) { //remove specific shortcode remove_shortcode('adrotate'); //add dummy shortcode which returns a blank string add_shortcode('adrotate', 'dummy_adrotate_shortcode'); } return $content; } //hook into filtermanagement add_filter('the_content', 'remove_shortcode_from_index');




nice ……………. its help me in my project
Pingback: Top 160 Tutoriais WordPress – incluindo Basico, Desenvolvimento e Plugins – Site para Empresas – Blog sobre Internet e Criação de Site
Pingback: Mejoras gráficas para el blog | La Bitácora del Tigre