vbkun
Forum Replies Created
-
Forum: Plugins
In reply to: [qTranslate X] Getting qTranslate-X to work with Advanced Custom FieldsAnyone knows if this still actually works?
Just installed qtranslate x ( 3.2.9 ) + Advanced Custom Fields ( 4.4.1 )+ acf qtranslate (1.7.6) and isn’t really working, seems something is odd in the field filtering, its leaving ‘left overs’ and the vaues just keep pilling up like:
“[:pt-br]oi?[:pt-br][:pt-br]<!–:pt-br–><!–:pt-br–><!–:pt-br–><!–:pt-br–>soi?” (this is actually what shows up in my seccondary language, english)
Forum: Plugins
In reply to: [Qtranslate Slug] permalink for other languagesHad the same need here.
Checked the DB and the ‘official’ slug in wordpress is the default lang slug, that’s why the get_permalink just returns the default slug.
Translated slugs are metas in the post meta table, their key is ‘_qts_slug_previx’, so I built a quick function to pick the slug from id using wordpress’ get_post_meta:
function getLanguageSlug($id, $lang){ $post = get_post($id); $slugArray = get_post_meta( $id, '_qts_slug_'.$lang ); echo $slugArray[0]; }Just add to your functions, provide the id and the language prefix like this:
getLanguageSlug(41, 'en')and it will echo the slug in the requested language.
Hope this is also useful to someone else.
Forum: Plugins
In reply to: [Advanced Custom Fields: Image Crop Add-on] Getting link to original image?Quick fix/workaround:
I did some peaking in the DB, seems the field saves a meta that contains 2 things, original image ID and Cropped image ID. After that, depending on how you configure it (object or url or id), it process then to return either just the ID from the db or fetch requested info.
So I cam up with the ‘dirtiest/quickest’ way to workaround, make it return the same object that is saved to DB containing only both ids.
To do this:
1- Add another return option, in ver. 4.3.9 this would be in line 274, change:
'choices' => array( 'url' => __("Image URL",'acf'), 'id' => __("Image ID",'acf'), 'object' => __("Image Object",'acf') ),to:
'choices' => array( 'url' => __("Image URL",'acf'), 'id' => __("Image ID",'acf'), 'object' => __("Image Object",'acf'), 'original_object' => __("Original Object (Original+Cropped)",'acf') ),2- The ‘built of returns’ is just a series of if else, so in line 528 add another ifelse for the new option:
if( $field['save_format'] == 'original_object' ){ $value = $data; }This will make the plugin return a std class object containing the 2 images ids, example:
stdClass Object ( [original_image] => 110 [cropped_image] => 135 )Forum: Plugins
In reply to: [Advanced Custom Fields: Image Crop Add-on] Getting link to original image?I’m not sure why this is set as [resolved].
Same problem here, using the plugin ver 1.4.1 and ACF 4.3.9.
Array is not displayed as an option and it’s neither included in acf-image-crop-v4.php. Just ‘url’ ‘id’ and ‘object’.
Was it removed due some problem?
Forum: Fixing WordPress
In reply to: Search Query – Exclude Custom Posts where Cusom Field Value is YesThanks Craig,
I didn’t knew I could actually the WP_Query with the pre_get_posts hook, got it that I gotta merge them, did something similar before, this part should not be an issue here so I guess this is solved.
Thanks again.
Forum: Fixing WordPress
In reply to: Search Query – Exclude Custom Posts where Cusom Field Value is YesI was trying a step-by-step approach, since i never dealt with the pre_get_posts before, so I was trying to filter using the custom post only and then move to next step (how would i merge results/solve the situation ‘posts that doesn’t have this field).
Oddly I couldn’t even get the results from the posts that had values for that field. So, adding this experience to your comment, I guess the query just doesn’t work at all with that combination since it wasn’t built for that.
Then from your example I understand that the object from WP_Query() is equal to the initial query object, in structure. So then i could do something like:
function search_filter($query) { if ( $query->is_search ) { //all WP_Query() stuff here return $query; } } add_filter('pre_get_posts', 'search_filter');To use WP_Query to modify the search query trought pre_get_posts hook?
(from your example I think yes but I’m not sure if I understood you correctly);