Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function wp_get_attachment( $attachment_id ) {
- $attachment = get_post( $attachment_id );
- return array(
- 'alt' => get_post_meta( $attachment->ID, '_wp_attachment_image_alt', true ),
- 'caption' => $attachment->post_excerpt,
- 'description' => $attachment->post_content,
- 'href' => get_permalink( $attachment->ID ),
- 'src' => $attachment->guid,
- 'title' => $attachment->post_title
- );
- }
- function aioseop_change_canonical($url) {
- global $wp_query;
- $new_url=$url;
- $permlink=get_permalink();
- if (isset($wp_query->query_vars['image'])) {
- $imgvar = trim(explode('/', $wp_query->query_vars['image'])[0]);
- $attachment_meta = wp_get_attachment($imgvar);
- $new_url= $permlink . 'images/' . $imgvar . '/' . toAscii($attachment_meta['title']);
- }
- return $new_url;
- }
- function aioseop_change_title($title) {
- global $wp_query;
- $new_title=$title;
- if (isset($wp_query->query_vars['image'])) {
- $imgvar = trim(explode('/', $wp_query->query_vars['image'])[0]);
- $attachment_meta = wp_get_attachment($imgvar);
- $new_title = $attachment_meta['title'];
- }
- return $new_title;
- }
- function aioseop_change_description($description) {
- global $wp_query;
- $new_description = $description;
- if (isset($wp_query->query_vars['image'])) {
- $imgvar = trim(explode('/', $wp_query->query_vars['image'])[0]);
- $attachment_meta = wp_get_attachment($imgvar);
- $new_description = strip_tags($attachment_meta['caption']);
- }
- return $new_description;
- }
- add_filter('aioseop_canonical_url', 'aioseop_change_canonical' );
- add_filter('aioseop_title', 'aioseop_change_title' );
- add_filter('aioseop_description', 'aioseop_change_description' );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement