• Resolved Ricky Poon

    (@poonasor)


    Just curious is there a way to display the helpful plugin using the shortcode and hiding the default place it displays right after the content?

    Thank you for the great plugin

    • This topic was modified 5 years, 2 months ago by Ricky Poon.
Viewing 1 replies (of 1 total)
  • Plugin Author Pixelbart

    (@pixelbart)

    Howdy!

    You can disable automatic output in Helpful’s preferences and place the shortcode into the content by hand.

    To do this, go to Helpful -> Settings -> General -> Hide Helpful in post content

    Then you can place the shortcode by hand, or do the following (functions.php):

    
    <?php
    
    /**
     * Place the Helpful Shortcode automatically after the content.
     *
     * @see https://helpful-plugin.info/documentation/shortcodes/
     *
     * @param string $content The current content of the post.
     * @return string
     */
    function custom_add_helpful_after_the_content( $content ) {
    
    	global $post;
    
    	$post_type = 'post';
    
    	/* only in singles and post type "post" */
    	if ( is_singular() && $post->post_type === $post_type ) {
    		$helpful_shortcode = do_shortcode( '[helpful heading="My new heading!" post_id="' . $post->ID . '"]' );
    	}
    
    	return $content . $helpful_shortcode;
    }
    
    add_filter( 'the_content', 'custom_add_helpful_after_the_content', PHP_INT_MAX );
    

    Hopefully this could help you a bit.

Viewing 1 replies (of 1 total)
  • The topic ‘Display using shortcode and hide it right after the content’ is closed to new replies.