WordPress.org

Support

Support » Themes and Templates » Customizr » Page of Posts in Customizr

Page of Posts in Customizr

  • Kiffster

    @kiffster

    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.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author nikeo

    @nikeo

    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

    Kiffster

    @kiffster

    Thank you kindly. Will give that a go.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Page of Posts in Customizr’ is closed to new replies.
Skip to toolbar