Programming

Get the youtube video ID from url

If you are struggling to get the video id (i.e.v=id)  from YouTube’s URL, use the below function.

Hits: 66

Standard
Filter and Hooks, Programming

Issue : Outlook Overriding Font from Arial to Times New Roman

If your are receiving the email on Outlook in Times New Roman, add the following code inside the head tag.

If you are facing the similar issue in CF7 (contact form 7),  just attach the script in the body using CF7 filter.

P.S. This resolved my issue 🙂 .

Hits: 43

Standard
Programming

Get photos from Instagram using PHP & CURL

To display your Instagram photos on your site, you shall generate the access token.  To generate the Access token  :

  1. Login on your  Instagram account .
  2. Visit  site :  http://instagram.pixelunion.net/  and click on “Generate Access Token” button
  3. Use the generate access token in the  : https://api.instagram.com/v1/users/self/?access_token=ACCESS-TOKEN to get the  posts of  your Instagram account

You can use the following function to get Instagram photos  or update it as per requirement.

Here, $limit  is the number of photos you would like to display in your website.

 

Hits: 2469

Standard
Filter and Hooks, Programming, WordPress

Remove special character while uploading Media

The media having special characters in its name,  may not be visible in the front-end, therefore, we should remove the special character while  uploading media in the WordPress dashboard.   wp_handle_upload_prefilter, is admin filter that is called by the wp_handle_upload function, which helps to alter the filename before the file is moved to its destined location. The sole parameter $file, represent a single element of the $_FILES array.

Adding the aforementioned filter in the function.php, removes the special character from the name of the media prior to uploading it in WordPress dashboard.

Hits: 18

Standard
Programming, WordPress

WPML custom post type slug translation

If you are struggling to translate the slugs for custom post type then, read this article and try to implement the solution in your website.

Suppose, we have custom post type ‘programs‘ and we want to update its slug for each available languages.

I would like to recommend the following steps for translating the custom post type slugs in different languages :

  1. Go to WPML -> String Translation
  2. From the String Translation admin screen search for the English slug “programs”, select the available strings and delete it. Similarly, from the String Translation admin screen search for the slug “programas” and delete it. In short, delete any string translation for related custom slugs.
  3. Go to WPML-> Translation Management-> Multilingual Content Setup and in the Custom posts slug translation options, check the box to “Translate custom posts slugs (via WPML String Translation).” and click Save.
  4. Then, scroll down to custom post types, where you can see the lists for posts ready to to be translated. Select the post to be translated and Save it. Once the page refreshes, you can see the original posts slug  and fields where you can enter the slugs for each of your secondary languages. Save the translated custom post slugs.
  5. Check the posts links for each language.Finally, you can see the fine links with the translated slug for each language.

Hits: 28

Standard