How to insert a css class from the custom field in a url?
-
Created a custom field “class” with the value “dsbld”.
There is a page with links to posts. How in the loop check custom field and assign to the link class=”dsbld”?url code:
<a href="'.get_permalink($udt_project->ID).'" title="'.esc_attr($udt_project->post_title).'">
All block code:
$display_media_size='aggressive-thumb'; if (has_post_thumbnail($udt_project->ID)) { $project_thumbnail_id = get_post_thumbnail_id( $udt_project->ID ); $image_src=wp_get_attachment_image_src($project_thumbnail_id, $display_media_size); $display_media_caption=''; if(isset($udt_portfolio_meta['display_media_caption']) && $udt_portfolio_meta['display_media_caption']!='') { $display_media_caption=$udt_portfolio_meta['display_media_caption']; } $display_media_caption_small = ''; if(isset($udt_portfolio_meta['display_media_caption_small']) && $udt_portfolio_meta['display_media_caption_small']!='') { $display_media_caption_small=$udt_portfolio_meta['display_media_caption_small']; } echo '<div class="thumb" data-project-categories="'.$project_categories.'"> <a>ID).'" title="'.esc_attr($udt_project->post_title).'"> <div class="thumb_img"><img src="'.$image_src[0].'" alt="'.esc_attr($udt_project->post_title).'"></div> <div class="thumb_text">'.$display_media_caption.'<span>'.$display_media_caption_small.'</span></div> <div class="thumb_caption">'.esc_attr($udt_project->post_title).'</div> </a> </div>'; }
- The topic ‘How to insert a css class from the custom field in a url?’ is closed to new replies.