• how to show one of my pages under the post.
    My posts is not very llong and i want a specific page to show under my blogpost.

    I found some shortcut plugins but i cant use shortcut in single.php and i dont want to att the shortcut to all my posts.

    how can i do this in php?

Viewing 6 replies - 1 through 6 (of 6 total)
  • do a thumbnail, or a link or a (you say one page) cut and paste.
    If it is a page why would you want it as a temporary post. maybe
    to show how it looked at a specific time. if it is a page then just call
    it a static page. try embedding it in the post. still doesn’t sound right.

    Thread Starter zookie_333

    (@zookie_333)

    have 500 posts with small seo content and i want to show my productpage under each post. I can ofcourse copy my produktspage and make a post of it. It must be a commando get_post…id123 i can cut in in single.php

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    Use a filter on the_content() to add content below the content of a pos

    https://codex.www.ads-software.com/Plugin_API/Filter_Reference/the_content

    so in your filter, you’d get the content of that post, format it up into a string, and return $content . $addtional_content

    Thread Starter zookie_333

    (@zookie_333)

    so what can that string look like? I′m not so good in php…..

    add_filter( 'the_content', 'featured_image_before_content' ); 
    
     function featured_image_before_content( $content ) {
        if ( is_singular('post') && has_post_thumbnail()) {
            $thumbnail = get_the_post_thumbnail();
    
            $content = $thumbnail . $content;
    
    		}
    
        return $content;
    }

    i want to narrow it down do one specific post. How to do that?

    Moderator Steven Stern (sterndata)

    (@sterndata)

    Volunteer Forum Moderator

    I think this is closer to what you want.

    add_filter( 'the_content', 'featured_image_before_content' ); 
    
     function featured_image_before_content( $content ) {
        $post_to_get = 123; // change to your target post
        if ( get_the_ID() == $post_to_get ) {
           return $content;
           }
        if ( is_singular('post') {
            $add_post = get_post( $post_to_get );
            $addl_content = $addl_post->post_content;
            $addl_content = apply_filters( 'the_content', $addl_content );
            $thumbnail = get_the_post_thumbnail( $addl_post);
            $content = $thumbnail . $addl_content;
    		}
        return $content;
    }
    Thread Starter zookie_333

    (@zookie_333)

    Thanks, but i cant get it….

    <?php
    
    get_header(); ?>
    
        <div id="single_page_wrap" class="clearfix">
    
            <div class="container">
                <div class="row">
    
    <?php while (have_posts()) : the_post();?>
    
        <div class="col-md-8 col-sm-8 single_page_content">
                        <div class="single_title_image clearfix">
                            <h1><?php the_title(); ?></h1>
                            <?php the_post_thumbnail('full'); ?>
                        </div>
                        <!--single_title_image clearfix-->
    
                        <div class="single_content_text clearfix">
                            <?php
                            the_content();
                            ?>
    
    //start stern data 
    
    add_filter( 'the_content', 'featured_image_before_content' ); 
    
     function featured_image_before_content( $content ) {
        $post_to_get = 6461; // change to your target post
        if ( get_the_ID() == $post_to_get ) {
           return $content;
           }
        if ( is_singular('post') {
            $add_post = get_post( $post_to_get );
            $addl_content = $addl_post->post_content;
            $addl_content = apply_filters( 'the_content', $addl_content );
            $thumbnail = get_the_post_thumbnail( $addl_post);
            $content = $thumbnail . $addl_content;
    		}
        return $content;
    }
    
    // end of stern data 
    
                        </div>
                        <!--clearfix-->
                    </div>
                    <!--col-md-8 single_page_content-->
    <?php endwhile; ?>
                    <?php wp_reset_query(); ?>
                    <div class="col-md-4 col-sm-4 single_wid_wrap">
                        <?php get_sidebar('post') ?>
    
                    </div>
                    <!--col-md-4 single_wid_wrap-->
    
                </div>
                <!--row-->
            </div>
            <!--container-->
    
        </div><!--single_page_wrap-->
    
    <?php get_footer(); ?>

    Cant see post 6461 under my post. The code shows as text inside the content. I attach single.php for input,

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘add page to singe.php’ is closed to new replies.