• Hello there,

    I’m creating a custom plugin that handles the way excerpts display. It cuts off the “[…]” found at the end of each excerpt as it adds Drop Cap effect to the beginning of the excerpt.

    Everything works well for me except that when I apply the action/filters to both of my functions one of them will work while the other is not working.

    For example the function that cuts the “[…]” off will work and the function that adds the drop cap effect will not work.

    Or the function that adds the drop cap effect will work or the other will not work.

    If I separate the two functions and make each a different plugin, the first activated plugin will work.

    So, how can I make both of them work at the same time on the excerpt, or is that impossible??

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator Samuel Wood (Otto)

    (@otto42)

    WordPress.org Admin

    Code, dude. Post the code that’s giving you problems.

    We can’t diagnose things in a vacuum.

    Thread Starter daljirman

    (@daljirman)

    Never mind, I eventually came over the problem by assigning one function to all the jobs and everything is working as a magic now…

    I would like to know your solution daljirman. Otto…maybe you could help me out. Here is my code so far. Each filter will work on its own, but I’m trying to get them both to operate at the same time.

    <?php
    // Youtube
    function wp_youtube() {
    $video = get_the_content();
    $video = preg_replace('#\[video\]http://www.youtube.com/watch\?v=(.*?)\[/video\]#i', '<object type="application/x-shockwave-flash" data="http://www.youtube-nocookie.com/v/\\1&rel=0"><param name="movie" value="http://www.youtube-nocookie.com/v/\\1&rel=0" /><param name="wmode" value="opaque" /></object>',$video);
    return $video; }
    function wp_youtube_filter() { return wp_youtube(); }
    $filter = wp_youtube_filter;
    
    // Google
    function wp_google() {
    $video = get_the_content();
    $video = preg_replace('#\[google\]http://video.google.com/\[/google\]#i','<p>Hello</p>',$video);
    return $video; }
    function wp_google_filter() { return wp_google(); }
    $filter = wp_google_filter;
    
    // excecute filter
    function all_video_filter() { return $filter; }
    add_filter('the_content', 'all_video_filter' );
    ?>

    ok…you know what…this code bites and I’m a total noob…

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Multiple add_action and add_filter on the same tag is not working for me’ is closed to new replies.