Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Display components in specific page only.
#1
Hello,

How could I make some components display in only some pages instead of all?

Thanks.
Reply
#2
You can insert in your template something like:
Code:
<?php if (return_page_slug()=='thatpage') get_component('thatcomponent'); ?>
(replace thatpage by your page identifier (slug) and thatcomponent by your component id.)

...Or you could use the DynPages plugin.
Reply
#3
Thank you but I want the components to be on the sidebar, plus I have a lot of pages in my website.
Reply
#4
If you give every component the same id as their corresponding page slugs, you can insert this in the sidebar:
Code:
<?php get_component(return_page_slug()); ?>
That is, a page with slug my-page would display component with name my-page (if that component exists).
Reply
#5
I want to have one conponent for like twenty pages.
Reply
#6
Do those pages have something in common? (same parent page, or some string in the page slug, ...)

If not, something like
Code:
<?php
if (in_array(return_page_slug(),array(
    'slug1'
    ,'slug2'
    ,'slug3'
    // ...
    ,'slug20'
    ))) get_component('componentname');
?>
might work (not tested).
Reply
#7
Thank you.

Same parent actually.
Reply
#8
Then it's easier:
Code:
<?php if (get_parent(0)=='parentpage') get_component('componentname'); ?>
Reply
#9
Great, thanks. I figured it out and worked perfectly!!
Reply
#10
my question to this topic is that how would i have a topic header in the sidebar identified as per page then the content that i want in that sidebar ?
Reply
#11
leonku Wrote:my question to this topic is that how would i have a topic header in the sidebar identified as per page then the content that i want in that sidebar ?
If I understood what you're asking, get the Exec-PHP plugin and put this in the sidebar component.
Code:
<?php get_page_title(); ?>
Reply




Users browsing this thread: 1 Guest(s)