• Nazakat Ali

    (@nazakatali32)


    How do i convert this code into wordpress function.

    <?php
    add_filter('wp_get_attachment_link', 'add_gallery_id_rel');
    function add_gallery_id_rel($link) {
    	global $post;
    	return str_replace('<a href', '<a rel="prettyPhoto'.'" href', $link);
    }
    if ( $post->post_type == 'game' && $post->post_status == 'publish' ) {
    		$attachments = get_posts( array(
    			'post_type' => 'attachment',
    			'posts_per_page' => -1,
    			'post_parent' => $post->ID,
    			'exclude'     => get_post_thumbnail_id()
    		) );
    
    		if ( $attachments ) {
    			foreach ( $attachments as $attachment ) {
    				$class = "post-attachment mime-" . sanitize_title( $attachment->post_mime_type );
    				$thumbimg = wp_get_attachment_link( $attachment->ID, 'thumb', false);
    				echo '<li class="' . $class . ' game-thumbnail">' . $thumbimg . '</li>';
    			}
    
    		}
    	}
    ?>

The topic ‘Wrodpress function’ is closed to new replies.