sudo find . -print | grep -i '.*[.]php'
sudo find . -print | grep -i '.*[.]php'
First thing you need to do is install and activate the Polylang plugin. Upon activation, you need to visit Settings » Languages to configure the plugin.
The language settings page is divided into three tabs. The first tab is labeled‘Languages’. This is where you add the languages you want to use on your site.
You will need to add the default language, as well as select all other languages that users can choose on your site.
After adding the languages, switch to the ‘Strings Translations’ tab. Here you need to translate site title, description, and then choose the date and time format. If the language is in Spanish, you can convert it to English using Google Translate. But if it’s in a dialectical language like tigrinya, then the tigrinya translations should be done by a translation agency.
Last step in the configuration is the Settings tab. This is where you can choose a default language for your site and other technical settings.
Polylang makes it super easy to add content in different languages. Simply create a new post/page or edit an existing one. On the post edit screen, you will notice the languages meta box.
Your default language will automatically be selected, so you can first add content in your default language, and then translate it into others.
To translate, you need to click on the + button next to a language and then add content for that language.
Let’s say you wanted to use the post thumbnail feature of WordPress, but had a whole archive of posts that would take too much time to go through. For new posts, you can be specific and use the feature as intended. For old posts, you just want to use the first image it finds in the content for the thumbnail, or a default if none present.
Add this to functions.php or make a functionality plugin:
function catch_that_image() { global $post, $posts; $first_img = ''; ob_start(); ob_end_clean(); $output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches); $first_img = $matches[1][0]; if(empty($first_img)) { $first_img = "/path/to/default.png"; } return $first_img; }
To use it, use this code in the loop:
if ( get_the_post_thumbnail($post_id) != '' ) { echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">'; the_post_thumbnail(); echo '</a>'; } else { echo '<a href="'; the_permalink(); echo '" class="thumbnail-wrapper">'; echo '<img src="'; echo catch_that_image(); echo '" alt="" />'; echo '</a>'; }
I found that has_post_thumbnail wasn’t as reliable as the logic above.
Some very easy copy-and-paste code here to add to the template for blog posts to allow for Facebook “liking” of the article. Probably best in the single.php template underneath where it outputs the content of the post.
<iframe src="http://www.facebook.com/plugins/like.php?href=<?php echo rawurlencode(get_permalink()); ?>&layout=standard&show-faces=true&width=450&action=like&font=arial&colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" id="facebook-like"></iframe>
<?php $recent = new WP_Query("page_id=**ID**"); while($recent->have_posts()) : $recent->the_post();?> <h3><?php the_title(); ?></h3> <?php the_content(); ?> <?php endwhile; ?>
The above code can be used within the regular page loop. Replace **ID** with the ID of the page you wish to embed.
Cookie | Duration | Description |
---|---|---|
cookielawinfo-checkbox-analytics | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Analytics". |
cookielawinfo-checkbox-functional | 11 months | The cookie is set by GDPR cookie consent to record the user consent for the cookies in the category "Functional". |
cookielawinfo-checkbox-necessary | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookies is used to store the user consent for the cookies in the category "Necessary". |
cookielawinfo-checkbox-others | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Other. |
cookielawinfo-checkbox-performance | 11 months | This cookie is set by GDPR Cookie Consent plugin. The cookie is used to store the user consent for the cookies in the category "Performance". |
viewed_cookie_policy | 11 months | The cookie is set by the GDPR Cookie Consent plugin and is used to store whether or not user has consented to the use of cookies. It does not store any personal data. |