Match by heading not shortcode
-
Hello,
Thanks for the plugin – it’s a real time saver!
I’m not sure if this is any help for you at all but I needed to adapt the plugin so that users don’t have to enter the shortcodes after the nextpage tags (believe it or not this is too complex for our users). So I changed your for loop in /includes/class-simple-paginated-posts.php on line 276 to get the first heading in the html block of each page as a title. I also added a check to make sure it gets a heading (or shortcode) and if not fill it with a default (Page 1, Page 2 etc.). The code is:
for ( $i = 1; $i < ($numpages); $i = $i + 1 ) { //Match headings preg_match('|<h[^>]+>(.*)</h[^>]+>|iU',$pages[$i],$matchingHeadings[$i]); //If we found a match use it as our heading if(!empty($matchingHeadings[$i])){ //TODO:Strip out any innerhtml that may be there (spans, links etc.) $this->page_titles[] = trim($matchingHeadings[$i][1]);//1 is the inner part } else{ preg_replace_callback( "/$shortcode_pattern/s", array( $this, 'get_shortcode_atts' ), $pages[$i] ); } //No title found use default if(empty($this->page_titles[$i])){ $this->page_titles[] = __('Page ') . ($i + 1); } }
I’d love to see this added into the plugin if possible.
Thanks,
Jameshttps://www.ads-software.com/extend/plugins/simple-paginated-posts/
- The topic ‘Match by heading not shortcode’ is closed to new replies.