Forum Replies Created
-
AuthorPosts
-
August 14, 2015 at 1:19 am in reply to: Creating a page which lists posts from a specific category. #27279craig.haydonParticipant
Hi TH,
Unfortunately the get_posts (from above) didn’t work. (or at least i wasn’t able to get to work).
This is what i did to fix my question, and perhaps it will help other newbies like me.
1) created a new page template. (copy page.php and rename to page-template-page-blog.php)
2) added text (line 3) to the above new file (so its shows in WP admin). “* Template Name: Page with blog posts(cat=slug)”. You really can call it anything. The text that you enter here is what shows in WP admin (dashboard) in the page -> template (dropdown)
3) changed description to ‘* Displays posts in page based on slug’. This isn’t really necessary… but will help to remind you later what it does 🙂
4) modified content-extensions.php (its under library > structure) function attitude_theloop(){, so it now looks like this:function attitude_theloop() { global $post; if( is_page() ) { if( is_page_template( 'page-template-blog-image-large.php' ) ) { attitude_theloop_for_template_blog_image_large(); } elseif( is_page_template( 'page-template-blog-image-medium.php' ) ) { attitude_theloop_for_template_blog_image_medium(); } elseif( is_page_template( 'page-template-blog-full-content.php' ) ) { attitude_theloop_for_template_blog_full_content(); } elseif( is_page_template( 'page-template-page-blog.php' ) ) { $categ = $post->post_name; query_posts( "category_name=$categ&posts_per_page=10" ); attitude_theloop_for_archive(); } else { attitude_theloop_for_page(); } } elseif( is_single() ) { attitude_theloop_for_single(); } elseif( is_search() ) { attitude_theloop_for_search(); } else { attitude_theloop_for_archive(); } }
5) back in wp-admin, go to the page you want to change, and change its template to ‘Page with blog posts(cat=slug)’.
There’s probable an even easier or better way to do this, but this is what worked for me… 🙂
Enjoy
August 11, 2015 at 5:49 am in reply to: Creating a page which lists posts from a specific category. #27155craig.haydonParticipantHi Theme Horse Support Team.
I haven’t created a custom file, i am wanting to work within the bounds of the theme.
Thanks -
AuthorPosts