Unable to display multiple post types in same query (WPML WP_Query)

I had this problem with querying on two custom post types, using WP_Query. I had no problem querying for one type or the other in the array, but not both at the same time. Did not work: $args = array( ‘post_type’ => array(‘custom_type_1′,’custom_type_2’), ‘posts_per_page’ => 4 ); Did work: $args = array( ‘post_type’ => array(‘custom_type_1’), … Read more

Make theme translatable for WPML

You don’t have to make anything special for WPML, using the regular translation code should be enough. See I18n for WordPress Developers in the Codex. Code preparation style.css Add Text Domain and Domain Path to your theme’s style.css. Example: /* * Theme Name: My awesome theme * Text Domain: my_awesome_theme * Domain Path: /languages */ … Read more

wp_pagenavi function parameters [closed]

Why do you dont use the default functions from WP. As example the follow class, there you can use. class fb_pagination_example { public function content_nav( $nav_id, $pag_bar = TRUE ) { if ( $GLOBALS[‘wp_query’] -> max_num_pages > 1 ) : ?> <nav id=”<?php echo $nav_id; ?>”> <h1 class=”assistive-text”><?php _e( ‘Post navigation’, WP_BASIS_TXTD ); ?></h1> <?php … Read more

How To Write An Inner Join With WP Query

Ok so the way I was able to just show English properties on the user admin page was with this posts_request hook: add_filter(‘posts_request’, function($sql, $query) { $is_user_edit_page = ( isset($_SERVER[‘HTTP_REFERER’]) && strpos($_SERVER[‘HTTP_REFERER’], ‘user-edit’) !== false ); $is_property_sql = (strpos($sql, ‘property’) !== false); if ($is_user_edit_page && $is_property_sql) { $sql = str_replace(“‘sp'”, “‘en'”, $sql); } return $sql; … Read more

Remove WPML’s home_url filter

I found that it required removing 4 filters/actions to undo WPML’s home_url modification. Since I didn’t know what else this might break, I ended up changing my site’s logo to use site_url() which in my case was the same, but not changed by WPML. function disable_things(){ remove_filter( ‘page_link’, array( $this, ‘permalink_filter’ ), 1, 2 ); … Read more

Comments waiting but no comments found

Try to check on DB level. This SQL should give a list of all spam comments (which I assume skräpposter means): SELECT * FROM `wp_comments` WHERE `comment_approved` = ‘spam’; If the SQL gives 0 lines, the issue is with WordPress counting those comments, but in fact there are none. If the SQL gives a list, … Read more

WPML Get url without outputting

Actually WordPress lacks a real function to get posts by slug/post-name. But you can use get_page_by_path() for it so you don’t have to use a custom query: if(function_exists(‘icl_object_id’)) { $post = get_page_by_path(‘your-slug’); $id = icl_object_id($post->ID,’post’,true); $link = get_permalink($id); } The only difference here is that you must use the full path i.e. (‘parent-page/sub-page’) if you … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)