wpdb->get_var is returning a string.
Since the group_id is an int in the database, it seems wrong to fail when an int is passing in to the create.
Can’t that test be == (equals) rather than ===?
Of could could cast the values in the comparison to avoid type issues?
https://www.ads-software.com/plugins/groups/
]]>I googled like crazy for an answer to my problem or something similar but couldn’t find anything that would help, so gonna try it here.
What am I trying to do?
The website i’m creating will be using multiple a tab navigation on the top of the page. Each tab will show content for a specific group of people, ie. men or women. Each tab will show a different menu with pages in it, this is working if i assign pages to the corresponding tab page. Now the problem i’m having is with the pages that I want to show in all of the tabs. I want the selected tab to stay highlighted, and the corresponding menu to stay when going to a page that doesn’t have the corresponding tab as a parent (since it must be available to the other tabs too).
What have I tried?
I have tried to check if the page has a parent, if so then select that tab. If the page does not have a parent use the previous parent and select that tab. This way the tab should stay highlighted even though the page doesn’t have a specific parent.
What I don’t want?
I don’t want to make different versions of each page for each tab available. This way I would have to edit the same thing multiple times for each copy of the page.
What would be the best way to get the result i’m looking for?
I hope this is clear enough, and I hope someone can help me with this.
Thanks in advance!
Greetings,
Wversluys
ps. If you need more information let me know and ill update the question.
EDIT*
Here are some screens of the problem, first screen shows a working tab with the correct navigation shown (parent: the top-level parent of the page shown, wich determines the navigation shown in the bar).
Screen 1
The second screen shows a page without a parent (thus available to multiple tabs). This also shows and empty navigation bar (except from the page itself).
Screen 2
function is_tree( $pid ) { // $pid = The ID of the page we're looking for pages underneath
global $post; // load details about this page
if ( is_page($pid) )
return true; // we're at the page or at a sub page
$anc = get_post_ancestors( $post->ID );
foreach ( $anc as $ancestor ) {
if( is_page() && $ancestor == $pid ) {
return true;
}
}
return false; // we arn't at the page, and the page is not an ancestor
}
My default page template looks like this just to test. It is working to alter background colors but… All pages are yellow except page ID 11 which is orange. What am I doing wrong? Thanks so much!
if ( is_home() ) {
echo '<style type="text/css">body{background:black;}</style>';
} elseif ( is_tree( '11' ) == $post->post_parent ) {
echo '<style type="text/css">body{background:yellow;}</style>';
} elseif ( is_tree( '37' ) == $post->post_parent ) {
echo '<style type="text/css">body{background:orange;}</style>';
} else {
echo '<style type="text/css">body{background:red;}</style>';
}
]]>I have the following structure:
Glossary (ID = 74)
Glossary Category (Child Page)
Letter Page (Grandchild Page)
Term (Great-Grandchild Page)
What i want is for the Glossary Category title to appear on any child, grandchild and great-grandchild page of “Glossary”, or ID 74. Here’s what i have so far:
<?php } else if ( '74' == $post->post_parent || strpos($_SERVER['REQUEST_URI'],'/glossary/')!==false ) { ?>
<?php
$current = $post->ID;
$parent = $post->post_parent;
$grandparent_get = get_post($parent);
$grandparent = $grandparent_get->post_parent;
?>
<h1><?php if ($root_parent = get_the_title($grandparent) !== $root_parent = get_the_title($current)) { echo get_the_title($parent); } else { echo get_the_title($current); }?></h1>
Here’s what happens (Page: Title) with the above code:
Glossary: Glossary
Glossary Category: Glossary Category Title
Letter Page: Glossary Category Title
Term: Letter Page Title << i want this to also be Glossary Category Title.
Hopefully i’ve detailed this enough. Any help is greatly appreciated.
]]>$parent = $post->post_parent;
$grandparent = $parent->post_parent;
I hope someone can help.
i’ve got my categories set up as follows:
Section 1
– sub section a
– sub section b
– sub section c
Section 2
– sub section a
– sub section b
– sub section c
Section 3
– sub section a
– sub section b
– sub section c
If you’re in sub section x, how do you get the parent id, i.e. Section 1,2 or 3?
Any help is much appreciated as I’m still learning!
Thanks
]]>I have 4 or 5 main pages, all with subpages. One of these main pages is called About (ID is 2), and it has 5 subpages, like so:
On the sidebar for the pages, I have this code to show either the subpages or the sibling pages:
<?php $children = get_children("post_parent=" . $post->ID );
if( $children )
{
$output = wp_list_pages('title_li=&child_of=' .$post->ID. '&hierarchical=1&depth=1&echo=0');
} else {
$output = wp_list_pages('title_li=&child_of=' .$post->post_parent. '&hierarchical=1&depth=1&echo=0');
}
if($output) {
?>
<li>
<ul class="submenu">
<?php print $output; ?>
</ul>
</li>
<?php } ?>
Now, it works fantastically on every other page, except for 2 pages that are children of About.
So I thought to myself that there must be a problem with the code somewhere, so I placed a wp_list_pages function with the ID of the About instead of $post->post_parent. It worked great. So, I thought to go back to the root and see if it’s seeing its parent well. I placed this code in one of the pages in which the submenu doesn’t display (page ID is 6):
<?php $parent_title = get_the_title($post->post_parent); echo $parent_title;?>
<?php $parent_id = get_the_id($post->post_parent); echo $parent_id;?>
And, the result for that is : About6.
I went in and checked if it’s a child page in the WP admin, and it is. I’ve resaved it about 10 times, and it still displays the same.
I don’t know what the hell is going on… Help? Please? I don’t know where to look anymore, and I’m pretty sure that the initial code is correct because I’ve used it before on other sites.
]]>i have this structure:
HighestParentPage (id:4)
— SubPage (id:5)
— SubPage (id:6)
— — SubSubPage (id:7)
— — SubSubPage (id:8)
— — — SubSubSubPage (id:9)
How can i retrieve the id of the HighestParentPage (id:4) when i am in ChildPage SubSubPage with id:8 ?? So two layers deeper.
thank you
yavuz