WordPress.org

Ready to get started?Download WordPress

Forums

XML Sitemap & Google News feeds
NextGen Gallery singlepic images (2 posts)

  1. allista
    Member
    Posted 4 months ago #

    I like this plugin a way more then WordPress-SEO for its' simplicity and robustness. Unfortunately, XML-Sitemap is unable to list pictures posted through the NextGen Gallery plugin, on which my site is heavily relying. So I wrote a simple patch to enable it to handle the [singlepic] shortcode (at least). Maybe it will be usefull to someone:

    xml-sitemap-feed/includes/core.php:
    466			if('attached' == $which) {
    467				$args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image', 'numberposts' => -1, 'post_status' =>'inherit', 'post_parent' => $post->ID );
    468				$attachments = get_posts($args);
    469				if ($attachments) {
    470					foreach ( $attachments as $attachment ) {
    471						$url = wp_get_attachment_image_src( $attachment->ID, 'full' );
    472						$this->images[$post->ID][] = array(
    473										'loc' => esc_url( $url[0] ),
    474										'title' => apply_filters( 'the_title_xmlsitemap', $attachment->post_title ),
    475										'caption' => apply_filters( 'the_title_xmlsitemap', $attachment->post_excerpt )
    476										);
    477					}
    478				}
    				#check for NextGen singlepics
    				if (class_exists('nggdb')) {
    				    if (preg_match_all( '<code>\[singlepic id=[0123456789]+</code>', $post->post_content, $matches)) {
    					    foreach ($matches[0] as $img) {
    						    if (preg_match( '<code>=([0123456789]+)</code>', $img, $match)) {
    							    $img = nggdb::find_image($match[1]);
    							    $image = array('loc' => esc_url($img->imageURL),
    							                    'title' => $img->alttext,
    							                    'caption' => $img->alttext);
    							    $this->images[$post->ID][] = $image;
    						    }
    					    }
        				}
        			}
    			} elseif ('featured' == $which) {
    				if (has_post_thumbnail( $post->ID ) ) {

    *Note: <code> tags appearing in the snippet are actually backquotes transformed by the forum. They are part of regexps.

    https://wordpress.org/plugins/xml-sitemap-feed/

  2. RavanH
    Member
    Plugin Author

    Posted 4 months ago #

    Hi allista, thanks for sharing :)

Reply

You must log in to post.

About this Plugin

About this Topic