REST API + Polylang

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

"... none of the offered feeds [RSS does - mine] seem to include information on the language of the content...."

"It is because Frédéric, polylang’s author has not set his taxonomy property ‘show_in_rest’ => true ..."

"The plugin author is not planning to add this to the free version. The pro version will get something that could provide for this..."

function wpse_modify_taxonomy() {
    // get the arguments of the already-registered taxonomy
    $language_args = get_taxonomy( 'language' ); // returns an object

    // make changes to the args
    // in this example there are three changes
    // again, note that it's an object
    $language_args->show_in_rest = true;

    // re-register the taxonomy
    register_taxonomy( 'language', 'post', (array) $language_args );
}
// hook it up to 11 so that it overrides the original register_taxonomy function
add_action( 'init', 'wpse_modify_taxonomy', 11 );

It could be slow, it could be something else, but it works.

Source: How to know the language of a post through the WordPress REST API | WordPress.org

CSV to html

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

The link to the the latest version of WordPress plugin (Display a (html)table from one or more csv file), but I am using modified the old one (code is mess, but it works....)


  1. Only UTF-8 encoding is allowed. MS Office cannot create UTF-8 .csv file. Just use LibreOffice 🙂 It can.
  2. I do not use guessing about EOL, just use PHP built-in method to read/parse .csv
  3. Not all the customers are smart as you are, and word 'shortcode' could cause the heart attack. So let's make it simple. Added filter for content to create shortcode from the link to .csv file: just go to the media library, upload a file and add it to the post/page. The text between tags <a></a> will be displayed as a table name. See code below, added to functions.php file. The only problem right now that all tables will have the same classes: responsive, bordered, stripped, it's under html_class="" in the code. 99.99% is ok.
  4. First row is a list of headers, except, it will be ignored if it's empty/blank

add_filter( 'the_content', 'filter_the_content_in_the_main_loop' );
function filter_the_content_in_the_main_loop( $content ) {
  // Check if we're inside the main loop in a single post page.
 if ( /* is_single() && */ in_the_loop() && is_main_query() ) { return preg_replace('~<p><a\s[^>]*href=\"([^\"]*)\.csv\"[^>]*>(.*)<\/a><\/p>~siU', '[csvtohtml-create source_type="mine" title="$2" html_class="table table-bordered table-striped" source_files="$1.csv"]', $content);
  }
  return $content;
}
Table with Headers
x 2x 3x 4Cream
Latisse 3ml7oz9 oz
Latisse 5 ml13 oz
Table without Headers
Latisse 3ml7ozn/an/an/a9 oz
Latisse 5 ml13 ozn/an/an/a

Source: CSV to html – WordPress plugin | WordPress.org

WordPress RSS: Add image

1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...

If you would like to show ‘Featured Images’ in WordPress RSS feed, you need to add the following code in functions.php file for your WordPress theme:

add_action('rss2_item', 'add_my_rss_node');
function add_my_rss_node( ) {
  if( has_post_thumbnail() ):
    $thumbnail = wp_get_attachment_url (get_post_thumbnail_id ());
    echo "<image>{$thumbnail}</image>";
  endif;
}

 

Yandex.Metrica