WordPress.org

Ready to get started?Download WordPress

Forums

Include content, no title, from one post to another using shortcodes, (1 post)

  1. controltheweb
    Member
    Posted 3 years ago #

    I'm trying to "include" the content (only) from a post into another post using shortcodes. It's partially working. The problem is I am getting the title as well as the content, and I only want the content. Is there another way to do this? Or a way to fix the code shown below?

    The only info in an example post from my test site are the shortcodes:
    [digwp_include postidparam="15"]
    [digwp_include postidparam="16"]

    function digwp_includeContentShortcode( $atts ) {
         $thepostid = (int) $atts['postidparam'];
    
         if ( ! $post = get_post( $thepostid ) )
             return '<em>Invalid post/page ID.</em>';
    
             return apply_filters( 'the_content', $post->post_content );
    }
    add_shortcode("digwp_include", "digwp_includeContentShortcode");
    
    // SHORTCODE USAGE On post content HTML tab use [digwp_include postidparam="#"]

    This code is from Automattic/Wordpress developer Viper007Bond who posted the code here, and later by email told me it should work.

Topic Closed

This topic has been closed to new replies.

About this Topic