I'm building a WordPress site for a local newspaper. This newspaper currently has a "service directory" online which is a bunch of yellow-page style ads for different local businesses. Each of these ads is just a single image with a click-through, although there are two different sized ads (priced at different rates) that need to be displayed differently.

The data schema would look something like this (just formatting in JSON for readability -- I know it'll be stored as SQL):

service_link: {
    image: 'plumberad01.png'
    url: 'http://myplumber.com',
    type: 'large',
    active: true

I know I can create a new Page and manually add the images and their links, but management becomes a big hassle. What I want to do is create a custom page which just finds all the active service_links, and then formats them properly. I can easily write the PHP necessary to do that.

What I'm not sure of is how to get the service_links added to the database. All my searches just keep coming up with information about custom post types, which doesn't seem to be what I'm looking for as these aren't individual posts. They will only ever be viewed along with everything else.

My guess is I'd need to write a custom plugin (mainly so I can add the service_link management stuff to the menu in wp-admin), so I'm looking for a plugin doing something analogous or some kind of tutorial. I feel like this isn't an uncommon use-case (content that isn't a post), so I don't know why I'm having so much trouble finding information.

2 Answers 2


From what you describe these ads are separate pieces of information which you want to order and display based on their properties. That would mean storing them as custom posts is still the way to go. After all, posts are the way WordPress stores chunks of related information. That doesn't mean they have to be displayed separately. Menus are also stored as a post type, even if they are only included in templates that also include regular posts, and are handled in a completely different way.

Now you have the separate ads in a post type, you can use wp_query to select them and display them in a template. Roughly, there are two ways to go. If you control the template, you can create widget areas in appropriate places and write a widget that displays the ads. If you don't control the template you can write a shortcode and include it in regular posts/pages.

You would assemble all code (custom post type and widget/shortcode) in a plugin. The benefit of doing it this way would be flexibility for future developments. You could, for instance, place individual ads on content pages, if you would choose to do so.

  • Ah, thanks! That makes sense. I feel like "post" is an unfortunate name to be using. I'm pretty sure I'd never need to use this as a widget as they'll always be displayed only on one page. The wp_query stuff should be super simple to implement for this.
    – Mordred
    Commented Nov 17, 2016 at 9:51
  • Yeah, 'post' is unfortunate. It dates back to the time when WP was starting as a blogging platform.
    – cjbj
    Commented Nov 17, 2016 at 9:52

If I understand what you are looking for, the plug in,advance custom fields, should be useful. It allows you to create a page template that can include an image, text fields, etc, that can then be filled out for each page. See https://www.advancedcustomfields.com/

It is easy to use and set up, with good documentation. You create your field and then simply call each field in your page template.

  • I'll take a look at that.
    – Mordred
    Commented Nov 17, 2016 at 9:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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