Page of Posts in Customizr (3 posts)

  1. Kiffster
    Posted 1 year 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


  2. nikeo
    Theme Author

    Posted 1 year 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() )
    	//gets the posts
    	$your_post_list = get_posts($args) ;
    	//displays the posts
    	foreach ($your_post_list as $post) {
    			some rendering function here

    Hope this helps

  3. Kiffster
    Posted 1 year ago #

    Thank you kindly. Will give that a go.

Topic Closed

This topic has been closed to new replies.

About this Theme

About this Topic