Note that there are some explanatory texts on larger screens.

plurals
  1. POWP custom post type - set page as parent
    primarykey
    data
    text
    <p>My setup is as follows: <br/> - custom post type called 'Clients'<br/> - 2 levels of navigation (separate, second level only shows if current page has parent/children)<br/> - a page called Clients<br/> - the client posts have a custom template (single-clients.php)</p> <p>I want to make any 'client' post a subpage/child of the Clients page, so the navigation displays correctly on the clients page (it automatically lists subpages) and it's easy to add new clients.</p> <p>I have found a couple of scripts, but none of them did exactly what I wanted. </p> <p>Here's the main part of my sub navig code:</p> <pre><code>&lt;nav id='content_clients_navig' class='navig_general'&gt; &lt;ul&gt; &lt;?php global $post; //determine which navig should be displayed //if post has parent, display parent navig //else display the current post's navig $navig_display = ($post-&gt;post_parent) ? $post-&gt;post_parent : $post-&gt;ID; $menu_args = array( 'child_of' =&gt; $navig_display, 'title_li' =&gt; '' ); wp_list_pages( $menu_args ); ?&gt; &lt;/ul&gt; &lt;/nav&gt; </code></pre> <p>I call it by inserting this piece of code in my template files:</p> <pre><code>&lt;?php if (has_subnavig()) get_template_part( 'part', 'subnavig' ); ?&gt; </code></pre> <p>Here is has_subnavig:</p> <pre><code>function has_subnavig() { global $post; if( is_page() &amp;&amp; $post-&gt;post_parent){ return true; }else{ $children = wp_list_pages("title_li=&amp;child_of=".$post-&gt;ID."&amp;echo=0"); }; if($children){ return true; }else{ return false; }; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload