Jump to content


Photo
- - - - -

Displaying posts categories separately on a single page

categories WP_Query posts category

  • Please log in to reply
3 replies to this topic

#1 golok

golok

    Member

  • Members
  • 11 posts
  • LocationGeneva
  • Framework Version:2.4
  • Country: Country Flag

Posted 06 February 2013 - 01:00 PM

Displaying posts categories separately on a single page.

Hello,

On any "standard" WP template, one can easily display on a single page several blog posts categories, in separate blocs, using the following code and parameters:
 

Please Login or Register to see this Hidden Content

How can this be achieved on PageLines' templates? How can I have on the same page — but in different "blocs" — my posts from Category 1 and those from Category 2?

Also — although only partially related — it seems that when a page is set as the "Posts page" in the "Reading" settings, the Blog template take precedence over any other template chosen in the "Edit Page". For example, if my page "Blog" uses "Template 1", where a QuickSlider is set to appear above the Content in the active sections, theQuickSlider is not displayed and instead appears the Callout section added to the Blog page template.
 



#2 Danny

Danny

    Is Awesome!

  • Moderators
  • 15215 posts
  • LocationManchester, UK
  • Country: Country Flag

Posted 06 February 2013 - 01:21 PM

Hi,

 

For you to use that code, you can either use a hook or create your own section. However, I would recommend you have a look at AnyLoop in the PageLines store, as it may be what you're looking for.

 

Please Login or Register to see this Hidden Content



Also, when you set a page as the Post Page, its considered a Special Page, therefore going to Wordpress Admin Dashboard > Pages > Select the Page you have set as your post page will not do anything. Now that the Page is set as the Post page and considered special you need to go to Wordpress Admin Dashboard > PageLines > Page Options > Blog, to customisation the layout, sections etc...



#3 golok

golok

    Member

  • Members
  • 11 posts
  • LocationGeneva
  • Framework Version:2.4
  • Country: Country Flag

Posted 08 February 2013 - 07:16 PM

Rob,

Thank you for your input. Since I wasn’t really sure if AnyLoop was what I was looking for, I wrote a very basic section (my first one!) which retrieves the latest post of a given category, using first a new WP_Query, and other posts of the same category, using $theposts->load_loop();.

Please Login or Register to see this Hidden Content



I provide below my “amateur” code for the discussion, but I wouldn’t advise anyone to use it...:

Please Login or Register to see this Hidden Content

Although it would have been nice to have meta settings (to choose the category and the number of post), I’ll probably simply hardcode it as I don’t need such flexibility at present.

My “only” problem is about formatting. I noticed that if I use $theposts->load_loop(); posts are automatically formatted on two columns, even though “Magazine Layout Mode” is selected in the “Blog And Posts” page options. It’s ok, as I managed to format posts the way I want, but how could the formatting be controlled?

Once again, thanks for your help.
 



#4 Rob

Rob

    One Smart Egg

  • Members
  • 13575 posts
  • LocationEast Coast, USA
  • Framework Version:The Latest, of course
  • Country: Country Flag

Posted 08 February 2013 - 10:05 PM

Hi,

 

Try this plugin: 

Please Login or Register to see this Hidden Content

as it allows you to place code by shortcode, which means you can place it on any page, a post, a sidebar, etc.   In the shortcode, you can select a category, number of posts, and a number of other options.







Also tagged with one or more of these keywords: categories, WP_Query, posts category