38 posts

Show Link URL from HREF Attribute Using CSS

We can use CSS to display the URL of a link after the link. For this we don’t need to modify HTML as all work is done by CSS. This is the complete CSS to do this: a:after{ content: ‘ ‘ attr(href); // Style URL font-style:italic; color:blue; } The CSS […]

Add Pages, Custom Post Types in WordPress Site Feed

If you are running your WordPress site as a CMS, you may come across need to include pages from your site in the main feed, along with your posts. Well, the below code will give you that ability. function add_pages_to_rss_feed( $args ) { if ( isset( $args[‘feed’] ) && !isset( […]

Ultimate htaccess Redirects List

A list of useful htaccess redirects that you can easily implement on your site. Redirect removed pages Redirect deleted pages back to your site’s home page, or anywhere you want. RedirectMatch 301 /page1/?$ RedirectMatch 301 /page2/?$ If all pages share a common pattern, we can rewrite this in […]

Automatically Add Attributes to All Images in WordPress Posts

The below snippet will allow you to add an attribute to all images embedded in a WordPress post. function sumtips_image_attribute($content) { global $post; $pattern =”/<a(.*?)href=(‘|\”)(.*?).(bmp|gif|jpeg|jpg|png)(‘|\”)(.*?)>/i”; $replacement = ‘<a$1href=$2$3.$4$5 attribute=”attribute_value”‘; $content = preg_replace($pattern, $replacement, $content); return $content; } add_filter(‘the_content’, ‘sumtips_image_attribute’); Replace attribute=”attribute_value” to whatever attribute you need. Example: function sumtips_image_attribute($content) { […]