Site logo

[Support request] After First Paragraph code not working

Home Forums Support [Support request] After First Paragraph code not working

Home Forums Support After First Paragraph code not working

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #2466516
    Kartik

    I want to install after first paragraph code

    add_shortcode(‘portable_hook’, function($atts){
    ob_start();
    $atts = shortcode_atts( array(
    ‘hook_name’ => ‘no foo’
    ), $atts, ‘portable_hook’ );
    do_action($atts[‘hook_name’]);
    return ob_get_clean();
    });

    add_filter( ‘the_content’, ‘insert_featured_image’, 20 );
    function insert_featured_image( $content ) {
    global $post;
    $inserted_hook = do_shortcode(‘[portable_hook hook_name=”after_first_paragraph”]’);
    if ( is_single() && ! is_admin() ) {
    return prefix_insert_after_paragraph( $inserted_hook, 1, $content );
    }
    return $content;
    }
    function prefix_insert_after_paragraph( $insertion, $paragraph_id, $content ) {
    $closing_p = ‘</p>’;
    $paragraphs = explode( $closing_p, $content );
    foreach ($paragraphs as $index => $paragraph) {
    if ( trim( $paragraph ) ) {
    $paragraphs[$index] .= $closing_p;
    }
    if ( $paragraph_id == $index + 1 ) {
    $paragraphs[$index] .= $insertion;
    }
    }
    return implode( ”, $paragraphs );

    to my one of the site fifafootballworldcup.live but issue is when i add with code snippet the above code goes to element section and in new elements hook under hook name “after_first_paragraph” not showing

    #2466517
    Kartik

    we already remove the cache

    #2466535
    Fernando
    Customer Support

    Hi Kartik,

    May we know how you exactly added this PHP snippet?

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.