How to link 2 categories (Sync)

Place this in your theme functions: function mysite_clone_post($post_id, $post, $update) { if(!$update && in_category(‘home cat’, $post)) { //not handled updates and will only run if in this category $post_fields = array( ‘post_author’, ‘post_date’, ‘post_date_gmt’, ‘post_content’, ‘post_content_filtered’, ‘post_title’, ‘post_excerpt’, ‘post_status’, ‘post_type’, ‘comment_status’, ‘ping_status’, ‘post_password’, ‘post_name’, ‘to_ping’, ‘pinged’, ‘post_modified’, ‘post_modified_gmt’, ‘post_parent’, ‘menu_order’, ‘post_mime_type’, ‘guid’, ‘tax_input’, ‘meta_input’); $postarr … Read more

Replicating the WP_Query ‘s’ param with $wpdb

It seems that you in your INNER JOIN, you are joining on wp_term_relationships.object_id == wp_posts.post_title which is erroneous, since object_id is the post-id in this case-scenario. I want all IDs (post-ids) SELECT ID FROM $wpdb->posts Who have a record in the wp_term_relationships table // Now we are comparing the correct columns INNER JOIN $wpdb->term_relationships ON … Read more

Using polylang, how can I see which post is the “original” and which are the “translated children”? [closed]

polylang stores translation in a taxinomy but it’s better to access them with the polylang object like that : // test if the plugin polylang is present if (isset($GLOBALS[“polylang”])) { $translations = $GLOBALS[“polylang”]->model->post->get_translations($post->ID); // $translations contains an array with all translations of the post } all translations are interconnected then there is no parent translation. … Read more

get_locale() behaving strange in same functions.php file

You try this example <?php // outputs a list of languages names ?> <ul><?php pll_the_languages(); ?></ul> <?php // outputs a flags list (without languages names) ?> <ul><?php pll_the_languages(array(‘show_flags’=>1,’show_names’=>0)); ?></ul> <?php // outputs a dropdown list of languages names ?> <?php pll_the_languages(array(‘dropdown’=>1)); ?>

WordPress multilingual website domain and folders

Providing you’ve already updated the internal links and that example.jp points to the same place on the filesystem as example.com (via CNAME and appropriate server config changes) then you don’t necessarily need to rewrite to example.com, since example.jp accesses the same files. Trying to rewrite to a different domain will implicitly trigger an external redirect … Read more

How to display on the blog page the posts corresponding to the selected language, using Polylang

you can add the lang parameter to your loop arguments like so $loop = new WP_Query( array ( ‘post_type’ => ‘post’, ‘lang’ => pll_current_language(‘slug’), //returns ‘en’ for example ‘posts_per_page’ => 10, ‘post_status’ => ‘publish’, ) ); However this is not the better practice because by doing that way we override the main query which is … Read more