• Hello!
    Im trying to get on my front page a static page and under it latest posts from my blog.
    After trying all possible combinations at the “customize it” site the front page shows either the page or the posts. How to make both appear at the same time?
    I have seen some php solutions but Im not that skilled for that. Is there anything easier.
    Thank you!

Viewing 10 replies - 1 through 10 (of 10 total)
  • Sorry Zewel,
    without using a little bit of php is not possible atm.
    If you want I can give you a small piece of code to achieve that..

    Thread Starter Zewel

    (@zewel)

    Hello d4z_c0nf
    Thank you for fast answer!

    Do I need for that start with childs theme? (I couldnt make it before)

    Could you please send it to me?

    Thank you!

    Thread Starter Zewel

    (@zewel)

    I see you have made a plugin Childify Me! I should give it a try.

    Hi Zewel,
    once you set up your child-theme, this is the code you have to add in its functions.php

    /* add widget area before the blog, after the featured pages, only in home */
    add_filter( 'tc_default_widgets' , 'add_featured_page_widget' );
    function add_featured_page_widget( $defaults ) {
        $defaults['fp_widgets'] = array(
                        'name'                 => __( 'Featured Pages Widget' , 'customizr' ),
                        'description'          => __( 'After the featured pages area on home' , 'customizr' )
        );
        return $defaults;
    }
    
    add_action('__before_main_container' , 'display_my_fp_widget', 15 );
    function display_my_fp_widget() {
        if ( ! tc__f('__is_home') )
            return;
    
        dynamic_sidebar('fp_widgets');
    }
    add_filter('widget_text', 'do_shortcode');
    /* shortcode to display a page/post content + title */
    add_shortcode('tc_post', 'do_tc_post');
    function do_tc_post( $atts ){
        $default = array(
            'id'         => '',
        );
    
        $atts = shortcode_atts($default, $atts);
    
        if ( ! isset($atts['id']) )
            return;
    
        $_post = get_post($atts['id']);
        if ( ! isset($_post) )
            return;
        ob_start();
        printf('
            <article id="%1$s" class="post-%1$ page type-page status-publish hentry row-fluid">
              <header class="entry-header">
                <h2 class="entry-title">%2$s</h2>
              </header>
              <section class="entry-content">
                 %3$s
              </section>
            </article>',
            $_post -> ID,
            $_post -> post_title,
            apply_filters('the_content', $_post -> post_content)
        );
    
        $html = ob_get_contents();
        if ( $html ) ob_end_clean();
    
        return $html;
    }

    then add a new text widget in the new widget area and write:
    [tc_post id="ID_PAGE_YOU_WANT_TO_SHOW"].
    Hope this helps.

    Thread Starter Zewel

    (@zewel)

    Thank you!

    I will try.

    I’ve created this widget in the php file. My problem is my blog page is displaying my posts from a specific category but when I put the page ID for my blog page in, it doesn’t display the posts shown on the page as there is no material on the actual page. How can I get the widget to display the recent posts?

    https://www.energyforlife.net.au/blog/

    Thread Starter Zewel

    (@zewel)

    Hello d4z_c0nf
    It worked I tried just now!!! It is amazing, Im so happy. I gladly donated on your pluggin page.

    Hi Zewel,
    glad to hear you solved and .. thanks ??

    Abe15

    (@abe15)

    Hi d4z_c0nf!
    I have tried this but I have the same problem as hodgy06. I put the ID for my blog page in the featured page text widget, after which the front page only shows the blog page title but no recent posts. How can I get the recent posts displayed on front page?
    Thank you!

    d4z_c0nf, Please help.

    What is the post id, and where do I find it?

    Please note I’m using 3.3.20 and wp 4.2

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘lates posts and static page on front page’ is closed to new replies.