Title: Wrodpress function
Last modified: August 21, 2016

---

# Wrodpress function

 *  [Nazakat Ali](https://wordpress.org/support/users/nazakatali32/)
 * (@nazakatali32)
 * [12 years ago](https://wordpress.org/support/topic/wrodpress-function/)
 * 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.

## Tags

 * [code](https://wordpress.org/support/topic-tag/code/)
 * [function](https://wordpress.org/support/topic-tag/function/)

 * In: [Fixing WordPress](https://wordpress.org/support/forum/how-to-and-troubleshooting/)
 * 0 replies
 * 1 participant
 * Last reply from: [Nazakat Ali](https://wordpress.org/support/users/nazakatali32/)
 * Last activity: [12 years ago](https://wordpress.org/support/topic/wrodpress-function/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
