WordPress.org

Ready to get started?Download WordPress

Forums

Customizr
Page of Posts in Customizr (3 posts)

  1. Kiffster
    Member
    Posted 8 months ago #

    Hi there,
    apologies for the probably very basic question...

    I want to create various Pages which have Sliders at the top (and possibly some other static content) and then posts from a specific category below. It seems that the best way to do this would be with Page Templates, and specifically Page of Posts.

    I have found this link http://codex.wordpress.org/Page_Templates#A_Page_of_Posts

    Which looks like what I want. It says I need to adapt it for the HTML structure of my theme - which where I run into problems.

    I am struggling to work out how much of the code listed I need to paste into a copy of the custom-page.php of the Customizr theme, and whereabouts I need to paste it! My uneducated guesses (first attempts at playing with code for over 10 years!) have so far either yielded white screens or not shown my posts. Any help would be gratefully received....

    My work-in-progress site is http://www.paulkiff.com/new

    Thanks.

  2. nikeo
    Member
    Theme Author

    Posted 7 months ago #

    Hi kiffster, you could for example hook your list of post to the '__after_loop' hook. This will use the get_posts function.
    Your code would look like this :

    add_action ( '__after_loop' , 'display_some_posts' ) ;
    function display_some_posts() {
    	//does nothing if you are not displaying the wanted page
    	if ( YOUR-PAGE-ID != get_the_ID() )
    		return;
    	//gets the posts
    	$your_post_list = get_posts($args) ;
    
    	//displays the posts
    	foreach ($your_post_list as $post) {
    		?>
    			some rendering function here
    		<?php
    	}
    
    }

    Hope this helps

  3. Kiffster
    Member
    Posted 7 months ago #

    Thank you kindly. Will give that a go.

Reply

You must log in to post.

About this Theme

About this Topic