2016-03-04, 10:37:45
component only in child pages
|
2016-03-04, 16:04:43
Hmm... There are numerous ways to do it.
You can identify the target page by slug for example: Code: if(get_page_slug(false) == 'ma_slug') { Or, simply check if the current page has a specific parent then show your component: Code: $parent = get_parent(false); Or generally, when the same rules apply to all child pages on entire template, you can see whether page has parent then show your component: Code: if(!empty(get_parent(false))) {
2016-03-05, 03:13:18
(2016-03-04, 16:04:43)Bigin Wrote: ...Or generally, when the same rules apply to all child pages on entire template, you can see whether page has parent then show your component: It's that last one I need, thanks but it is giving me - Fatal error: Can't use function return value in write context in /var/sites... Just to be clear I have PHP Code: <?php if(!empty(get_parent(false))) { get_component('tagline')}; ?>
try this, that should do the trick:
Code: $parent = get_parent(false);
2016-03-05, 07:19:34
(2016-03-05, 03:28:23)Bigin Wrote: try this, that should do the trick: For some reason I get the component on all pages with that. I can check the variable is empty with print $parent (and it is). Using PHP Code: <?php $parent = get_parent(false);
2016-03-05, 08:20:59
(2016-03-05, 07:19:34)Timbow Wrote: For some reason I get the component on all pages with that. I can check the variable is empty with print $parent (and it is). Using Because $parent is of type object, you should cast it to a string: Code: $parent = (string) get_parent(false); |
« Next Oldest | Next Newest »
|
Users browsing this thread: 1 Guest(s)