Page/Parent name in Spoiler Title
-
Using WP UI Manuel Widget in sidebar to show 2 spoilers at https://perryfamilyroots.com. One for child pages of current page; one for sibling pages but wanted to show the page name in the spoiler title instead of just saying “child pages” and “sibling pages” since this is a genealogy site and those words might lead users to think it referred to children and siblings of the ancestor the page was about. I’m not a PHP programer and it took a while to figure it out but finally did.
Added just 5 lines to wp-ui.php. Only problem will have to make the changes again when next upgrade occurs. Any one know a way to do this outside of wp-ui.php? Don’t know if anyone else would want to use it but maybe Kav could just added it to the next upgrade
This is what the change looks like:function sc_wpspoiler( $atts, $content = null ) { // I ADDED THESE 3 LINES $currentpage = get_post(); $thispage = $currentpage->post_title; $thispageparent = get_the_title($currentpage->post_parent); extract( shortcode_atts( array( 'name' => 'Show Content', '_id' => false, 'style' => $this->options['tab_scheme'], 'fade' => 'true', 'slide' => 'true', 'speed' => false, 'closebtn' => false, 'showtext' => false, 'hidetext' => false, 'open' => 'false', 'post' => '', 'page' => '', 'elength' => $this->options['excerpt_length'], 'before_post' => '', 'after_post' => '', 'template' => '2', 'background'=> 'true' ), $atts)); // AND THESE 2 LINES $name = str_ireplace( '{$thispageparent}', $thispageparent, $name ); $name = str_ireplace( '{$thispage}', $thispage, $name );
And then used “$thispage} section contents:” and “Also in the {$thispageparent} section:” as titles for the spoilers.
You can see the results here.
NOTE: I originally had all 5 lines where the bottom 2 are but for a reason i don’t understand $thispageparent was being set to the current page title, not it’s parent. Moving the first 3 lines to their current position fixed that problem.
- The topic ‘Page/Parent name in Spoiler Title’ is closed to new replies.