Skip Navigation

[Resolved] Set WordPress Page as parent for CPT and highlight in Menu

This support ticket is created 5 years, 7 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 9 replies, has 3 voices.

Last updated by lotharK 5 years, 7 months ago.

Assisted by: Minesh.

Author
Posts
#1259309

Tell us what you are trying to do?
On a regular WordPress page i have a view which lists real estates (objects) (hidden link).
Once clicked on one item, it shows the real estates (objects) detail page (hidden link).
The menu-item of the corresponding WordPress page should be highlighted though.

Is there any documentation that you are following?
I already set a one-to-many relationship WordPress-Page_Object. Within the real estate (object) i selected the WordPress page as connected. This has no effect on the menu item though.

Is there a similar example that we can see?
I hope, it's quite obvious!?!

What is the link to your site?
hidden link (You need to be logged in, to see the actual page. I can provide login credentials, if you wish.)

#1259955

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - post relationship is different as its not stored like page (hierarchical) way.

Can you please send me login details and I will check if its possible to achieve what you looking for.

*** Please make a FULL BACKUP of your database and website.***
I would also eventually need to request temporary access (WP-Admin and FTP) to your site. Preferably to a test site where the problem has been replicated if possible in order to be of better help and check if some configurations might need to be changed.

I have set the next reply to private which means only you and I have access to it.

#1259985

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - if I understand correctly if you are on the following page:
=> hidden link

then, the menu "Objekte" should remain selected (highlighted) - is that correct?

#1259989

Exactly!

#1260099

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - to show highlighted menu item either it needs custom code where you can use the hook: wp_nav_menu_items

For example:

function func_nav_items_selected($items, $args) {
  global $post;
          if( $args->menu->slug == 'haupt-menue' and $post->post_type == 'object' ){
  			
          }
        return $items;
}
add_filter('wp_nav_menu_items', 'func_nav_items_selected', 10, 2);

Where:
- you need to adjust the code as needed.

Or use the plugin:
=> https://wordpress.org/plugins/wp-add-active-class-to-menu-item/

#1260211

Hi Minesh,
thanks again for your quick reply!

Did you add the mentioned code somewhere already? Because when i add it, i throws an error which says: "Fatal error: Cannot redeclare func_nav_items_selected() (previously declared in /var/www/clients/client60/web157/web/wordpress/wp-content/themes/bona_projekt/functions.php:193) in /var/www/clients/client60/web157/web/wordpress/wp-content/toolset-customizations/toolset-custom-code.php on line 10"

However, apparently the menu item "Objekt" still isn't highlighted when visiting the page hidden link and the li of the menu doesn't have any classes which indicate, it's active..

Is it the same for you?

#1260923

Hi,

Minesh is off and will be back tomorrow. you will get the respond when he returns if that's okay.

#1260933

Sure, thanks!

#1261801

Minesh
Supporter

Languages: English (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - yes, I've added that code to Toolset's "Custom Code" section:
=> hidden link

More info:
=> https://toolset.com/documentation/adding-custom-code/using-toolset-to-add-custom-code/

However, I just gave you guidelines that you may use the hook I shared or plugin I shared as this solution needs custom programming which is beyond the scope of our support policy.

I suggest to adjust the code as per your need or try to find a plugin that fulfills your need.

If you need custom programming for your project, please feel free to contact our certified partners:
=> https://toolset.com/contractors/

#1261815

Ok, i got it! I'll try to find a solution based on your suggestion. Thanks a lot for your time and effort!
Lothar