1

I want to build a homepage where I can show posts gathered from different categories and having the ability to choose such categories from the admin. I was thinking to use widgets for this. Is the right choice or is there a better way to do it?

I've found this plugin which seems to do what I need, but if possible I would prefer avoiding the use of a plugin.

5
  • You can do this in several ways, you can weather create a dedicated template that would suit your needs. You could declare dynamic sidebar zones and use widgets or directly get your desired posts with some WP_Queries
    – Sladix
    Nov 17, 2015 at 9:52
  • I don't want to show the posts in a sidebar, but in the content of the page. Can I declare a dynamic zone in there? And I know about WP_Queries, but how can I control them from the admin panel?
    – Carlo
    Nov 17, 2015 at 9:59
  • @PieterGoosen thanks, that is interesting, but if I understood it correctly, it's not really what I meant
    – Carlo
    Nov 17, 2015 at 11:01
  • I can maybe try it later, but it seems he's tying a single category to a specific page, using one common page template. I want to show several categories in a single page
    – Carlo
    Nov 17, 2015 at 11:08
  • I've done something very similar here ottawacitizen.com with a back end that lets you select multiple lists from multiple sources including external feeds. If you want to this far in, get ready to do a lot of coding or download a plugin. Feb 8, 2016 at 14:01

1 Answer 1

1

In order to register dynamic zones, you can follow theses steps :

  • Create a template for your home page
  • Assign that template to a page
  • Define that page as the Home page in Settings->reading
  • Register sidebar in your functions.php by using this function
  • Call the sidebar in your home template

In order to call your sidebar, use dynamic_sidebar. So if you named your sidebar with the id "home-sidebar-1", you can call it this way :

<?php dynamic_sidebar('home-sidebar-1') ?>

You can add as many sidebar as you have declared in your functions.php

3
  • so, just to be sure: even if the function is called dynamic_sidebar, I can use it also for the main content, not just in a sidebar, right?
    – Carlo
    Nov 17, 2015 at 10:15
  • 1
    Yes, you can call dynamic_sidebar anywhere you want. The zones will be editables in apparence->widgets. But you can't call dynamic_sidebar in the wysiwyg editor
    – Sladix
    Nov 17, 2015 at 10:32
  • that's fine. This is exactly what I needed
    – Carlo
    Nov 17, 2015 at 10:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.