Tagged: 

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1054532

    Hello, ich habe schon in einem Thread 2017 angemerkt, dass die images via Yoast Sitemap nicht korrekt indiziert werden.

    Konkret habe ich drei portfolio Einträge die jeweils mehrer Images enthalten aber in der Sitemap nur wenige Images angeführt werden.

    Was kann ich tun, damit die Images alle in der Sitemap enthalten sind?

    Beste Grüße, Michael

    #1055912

    Hey fragezeichen,
    Entschuldigung für die späte Antwort, meine Forschung zeigt, dass die Yoast-Sitemap Probleme beim Lesen des Shortcodes für den erweiterten Layoutersteller hat. @ismael hat an einer Funktion gearbeitet, die Yoast beim Lesen der Bilder hilft, please see this post
    Es wurde berichtet, dass es von anderen Benutzern funktioniert.

    Weitere Informationen zu Yoast-Sitemaps
    und über Bilder und die Sitemap

    — Translated with Google —

    Sorry for the late reply, my research shows that the Yoast sitemap has trouble reading the advanced layout builder shortcode, @ismael has worked on a function that helps Yoast read the images, please see this post.
    It has been reported as working by other users.

    Here is some more info about Yoast sitemaps
    and about images and the sitemap

    Best regards,
    Mike

    #1056783

    Hello Mike,

    since the code was postet 2017, I am wondering if its not part of the actual Enfold version?

    In the thread some minor changes are mentionend and I am not sure where to put the code.
    Is it possible for you or your team to either put the code in the next enfold version or to create a easy tutorial?

    I think it would be easier for all those people like me, who have no coding background and are afraid of messing up the whole system.

    Regards, Michael

    #1057523

    Hi,

    There not seem to be any changes – u can always go ahead and do those changes and let us know if we have to help anything else.

    Best regards,
    Basilis

    #1058880

    Hi,

    after update of functions.php with the code you´ve sent me – what steps do I need to take to re-generate the sitemap?

    Regdards,

    Michael

    #1059171

    Hi,
    You will only need to reload the site map, that is refresh the page: /sitemap_index.xml
    Here are some before and after screenshots of my localhost sitemap:
    Before:
    before
    After:
    after
    This is the code I added to the end of my child theme functions.php file in Appearance > Editor:

    //add image to site maps
    function avia_extract_shortcode($elements, $content) {
    	$container = array();
    	if(!empty($elements)) {
    		foreach ($elements as $key => $element)
    		{
    			preg_match_all($element['pattern'], $content, $shortcodes);
    				foreach($shortcodes[0] as $shortcode)
    				{
    					switch ($element['source']) {
    					case 'ids':
    							$src = '/ids=\\\'(\d+(,\d+)*)\\\'/';
    							break;
    					case 'src':
    							$src = '/attachment=\\\'(\d+)\\\'/';
    							break;
    					case 'sid':
    							$src = '/id=\\\'(\d+)\\\'/sim';
    							break;
    					default:
    							return;
    					}
    
    					$sid = array();
    
    					preg_match_all($src, $shortcode, $id);
    
    					if($src = 'sid') {
    						foreach($id[1] as $key => $value) {
    							$sid[] = $value;
    						}
    
    						$sid = implode(',', $sid);
    						$id[1] = $sid;
    					}
    
    					$container[] = $id[1];
    				}
    		}
    	}
    
    	if(!empty($container)) {
    		foreach($container as $key => $value) {
    			$container[$key] = explode(',', $value);
    		}
    	}
    
    	if (count($container) > 0) {
    		$container = call_user_func_array('array_merge', $container);
    	}
    
    	return $container;
    }
    
    function avia_filter_wpseo_sitemap_urlimages($images, $post_id)
    {
      $post = get_post($post_id);
      if (is_object($post)) {
    		$content = $post->post_content;
    		$elements = apply_filters('avf_add_elements_wpseo_sitemap',
    		 array(
    			'masonry' => array(
    				'pattern' => '/\[av_masonry_gallery [^]]*]/',
    				'source' => 'ids'
    			),
    			'gallery' => array(
    				'pattern' => '/\[av_gallery [^]]*]/',
    				'source' => 'ids'
    			),
    			'horizontal' => array(
    				'pattern' => '/\[av_horizontal_gallery [^]]*]/',
    				'source' => 'ids'
    			)
    		), $elements, $post_id);
    
    		$ids = avia_extract_shortcode($elements, $content);
    
    		foreach ($ids as $id)
    		{
    			$title = get_the_title($id);
    			$alt   = get_post_meta($id, '_wp_attachment_image_alt', true);
    			$src   = wp_get_attachment_url($id);
    			$images[] = array('src' => $src, 'title' => $title, 'alt' => $alt);
    		}
      }
    
      return $images;
    }
    add_filter('wpseo_sitemap_urlimages', 'avia_filter_wpseo_sitemap_urlimages', 10, 2);
    add_filter('avf_add_elements_wpseo_sitemap', function($elements, $postid) {
    	$image = array(
    		'image' => array(
    			'pattern' => '/\[av_image [^]]*]/',
    			'source' => 'src'
    		),
    		'accordion' => array(
    			'pattern' => '/\[av_slideshow_accordion(.+?)?\](?:(.+?)?\[\/av_slideshow_accordion\])?/sim',
    			'source' => 'sid'
    		),
    		'slideshow' => array(
    			'pattern' => '/\[av_slideshow(.+?)?\](?:(.+?)?\[\/av_slideshow\])?/sim',
    			'source' => 'sid'
    		),
    		'slideshow_full' => array(
    			'pattern' => '/\[av_slideshow_full(.+?)?\](?:(.+?)?\[\/av_slideshow_full\])?/sim',
    			'source' => 'sid'
    		),
    		'slideshow_fullscreen' => array(
    			'pattern' => '/\[av_fullscreen(.+?)?\](?:(.+?)?\[\/av_fullscreen\])?/sim',
    			'source' => 'sid'
    		)
    	);
    
    	return array_merge($image, $elements);
    }, 10, 2);

    Best regards,
    Mike

    #1059557

    Hello Mike,

    thank you for your help!

    I´ve inserted the code into my child theme.

    Now my sitemap looks much better and contains more Images.

    Thank you very much and regards,

    Michael

    #1059632

    Hi,
    Glad we could help, I assume we can close this now, but I like to ask first.
    Is there anything else we can assist with on this issue?

    Best regards,
    Mike

    #1059645

    Thanks, we can close this threat.

    Regards, Michael

    #1059725

    Hi,

    If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Image Sitemap Problem’ is closed to new replies.