Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Pulling in different Wordpress sidebars based on page id?

Featured Replies

Right, bit of a toughie here, I am completely stuck.

 

I have a website here: http://universitycompare.com/university-guide/anglia-ruskin-university/

 

This website has an advertisement plug-in that assigns a different sidebar per page and pulls in each Ad, lovely plug-in! Works like a charm!

 

I have one template, for each university profile page, and I have currently 100 universities, and I will be making 100 sidebars to go on each page, so they can have custom ads on each page.

 

How would I pull in a different sidebar per page instead of making 100 templates for the universities, which is a long process that I don't want to go through!

 

My ideal scenario would be to have a bit of code that can work out the page id and then I can name each sidebar based on the page id and then pull in that sidebar? - if that makes sense.

 

P.S I am really in the deep end here and no idea where to start - any help is help!

This is one way of doing it but would still require different sidebar.php files in the same way as creating different templates, but at least you could shove them in a sub folder that way.

 

<?php
if (in_category('20')) {include (TEMPLATEPATH . '/sidebar2.php');
}
else { include (TEMPLATEPATH . '/sidebar1.php');
}
?>

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.