Lrrr
Forum Replies Created
-
Forum: Plugins
In reply to: [Media Library Assistant] New/Extra URLHi Mike, as I read your post about rewriting, I solved successfully (as good as Im able to do it – maybe better ways there) similar issue in post here: http://wordpress.org/support/topic/pagination-87?replies=7
My goal was to rewrite one only one query though and even pagination, but I think it could be a good start point for you. There was a several problems what I had to be facing, but now its working as you can see on my blog. More is there. Good luck with the code and let us know!Forum: Fixing WordPress
In reply to: Mod_rewrite, htaccess works but IE!Forum: Plugins
In reply to: [Media Library Assistant] PaginationHi David and everyone, I get to work! Nice url pagination with MLA! Finally cannot say what make it work exactly and what causees the issue with IE(above), because I was trying almost everything and suddenly get it work. So I supposing it was rewrite parameter after rewrite rule together with rewrite rule itself(even some other??), but now I will put in general way the main things you should do to use that. I want highlight that this way maybe not the best, but I cant do it better, and it works. READ FIRST – THEN YOU ADD AND BACKUP BEFORE CHANGE!
1) put in your .htaccess these lines of code before wordpress code (this and the next code provides you ability to change attachment_tag slug also, so if you want it remain all “fotografie/tag” substitute with “attachment_tag” in this and subsequent code!):
RewriteCond %{QUERY_STRING} ^mla_paginate_current=([0-9^/]+) [NC] RewriteRule ^(.*)$ http://www.yourwordpresssite.com/?mla_redirect=$1 [R=301,QSA,NC,L] RewriteRule ^attachment_tag/(.*)/?$ fotografie/tag/$1 [R=301,QSA,L] RewriteRule ^fotografie/tag/([^/]+)/1/?$ fotografie/tag/$1 [R=301,QSA,L] #zalezi na poradi! RewriteRule ^fotografie/tag/([^/]+)/0/?$ fotografie/tag/$1/$2?mla_redirect=error [NC] RewriteRule ^fotografie/tag/([^/]+)/([0-9^/])/?$ index.php?attachment_tag=$1&mla_paginate_current=$2 [NC]2) Put this code in your function.php of your theme or childtheme (This code is to add redirect to WP. I dont know why, but its not works only with .htaccess or only woth this code. It works only together.):
function mla_rewrite( $wp_rewrite ) { $mla_rules = array( 'fotografie/tag/([^/]+)/?([0-9])?/?' => 'index.php?attachment_tag=$matches[1]&mla_paginate_current=$matches[2]' ); $wp_rewrite->rules = $mla_rules + $wp_rewrite->rules; return $wp_rewrite->rules; } add_filter( 'generate_rewrite_rules', 'mla_rewrite' );3) I made function for redirecting old query urls to new nice. It handles variables from .htacces. Redirecting this is good for seo and when you do not will want to parse mla gallery code in taxonomy template. So also this code belongs to function.php:
function handle_mla_redirect() { $url_query_var = explode('=',parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY)); $url = parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH); $url_host = get_bloginfo('url').parse_url($_SERVER['REQUEST_URI'],PHP_URL_HOST); $lom = ''; if ($url_query_var[2]!='') {$lom = '/';} $rep_url_fin = $url_host.'/'.$_GET["mla_redirect"].$lom.$url_query_var[2]; // print( '<br>presmeruj ted na: '.$rep_url_fin. '<br>' ); if( isset($_GET["mla_redirect"]) && ($_GET["mla_redirect"]=='error') ){ dk_return_404(); } if ( isset($_GET["mla_redirect"]) && (parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY)!='') ) { // print( '<br>presmeruj ted na: '.$rep_url_fin. '<br>' ); // print(parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY). '<br>'); wp_redirect($rep_url_fin, 301 ); exit; } } add_action('template_redirect', 'handle_mla_redirect'); /**/4) if you want to mla gallery shortcode in your taxonomy-template.php generate the nice urls instead the queries you can use before mentioned code which is dirty parsing of mla_shortcode and repasing urls generated for pagination. It here, so go above .
how it works together you can now test(if not currently, come back later): old link to new – http://www.danielkral.cz/fotografie/tag/mobilem?mla_paginate_current=2
and new one (try to browse) http://www.danielkral.cz/fotografie/tag/mobilem/2I must bring also resources which I found about this topic on web, it could be helpfull for anyone who want improve this: – link 1 – this works exactly opposite in this case, but gave a clue
helpfull but still do not understand why not works alone without .htaccess – codex WP link
Forum: Fixing WordPress
In reply to: Mod_rewrite, htaccess works but IE!I made it! about 3 days on it and have resolved – as I suspecting it was a tiny thing which causes it at all.
RW must not be:
RewriteRule ^fotografie/tag/([^/]+)/([0-9^/]+)/?$ http://www.danielkral.cz/index.php?attachment_tag=$1&mla_paginate_current=$2 [NC]
It must be:
RewriteRule ^fotografie/tag/([^/]+)/([0-9^/])/?$ index.php?attachment_tag=$1&mla_paginate_current=$2 [NC]I will write an article because this means, that way to have MLA galerry plugin paginated and with nice url’s is fully working now. Maybe its not in the best way but I cant do it better now and I feel fine π
Forum: Fixing WordPress
In reply to: Mod_rewrite, htaccess works but IE!Also in functions.php file must be the code:
function mlagallery_add_rewrite_rules() { // ruled altogether with htaccess - works only if its here and also same rule in htaccess ?!? what !? :D add_rewrite_rule('fotografie/tag/([^/]+)/?([^/]+)?/?$', 'index.php?attachment_tag=$matches[1]&mla_paginate_current=$matches[2]', 'top'); /**/ } add_filter('init', 'mlagallery_add_rewrite_rules'); function wpa_query_vars( $query_vars ) { array_push($query_vars, "attachment_tag", "mla_paginate_current"); return $query_vars; } add_filter( 'query_vars', 'wpa_query_vars' ); /**/So thats code. In php nothing changed if commenting out htaccess and mentioned above.
As you can see, rule in php handles also attachment_tag redirect which is working. So supposing something after that can cause issue.
Forum: Plugins
In reply to: [Media Library Assistant] PaginationI did several upgrades to code so now you dont need to create page named TAG in parent FOTOGRAFIE (in my case).
Even now its working ONLY nice URLs! wooow, im proud to myself and I will bring the code after if…
…if I (hope someone helps, I cant get it work for whole day) solve this annoying issue http://wordpress.org/support/topic/mod_rewrite-htaccess-works-but-ie?replies=1#post-4727521
Forum: Plugins
In reply to: [Media Library Assistant] PaginationUpdate: its true as I wrote, but for better understanding, BLOG section I have as such a cross-road, something (have to be always) first, therefore no slug for it. Just root. π
Forum: Plugins
In reply to: [Media Library Assistant] PaginationDavid, I carefully read your post. I have used your advices from “Pagination Revisited” article and my code is based on. But Im using it divergently.
My question about unexisting page “893798 etc.” is not much important but I supposed that this should be handled by “get_template_part( 'loop-error' );” so it isnt.Further,
For example, http://www.danielkral.cz/fotografie/tag/story?mla_paginate_current=$2 would become http://www.danielkral.cz/fotografie/tag/story/2; is that right?
You are fully right! But im not able to made it bullet-proof for opposite working. Both urls from these two working now, it should not be. (should works like: http://www.danielkral.cz/fotografie/tag/story?mla_paginate_current=$2 redirect to NICE URL. => only nice url active, visitor see nice only) This is not a question for you concerning your plugin. I “parsed” your code as you can see and changed urls to nice because otherwise it wasnt working correctly.
Finally dont be confused about my urls, its easy. My web is structural (should be), it have two basic sections: Blog and Photography (infact they are four, about me and contact yet, but these are single – want them in the row). Because mla plugin (attachment_tag taxonomy) im using in photography section, links in that section I want have based here, so in
.cz/fotografie/. Even the visitor browsing in gallery, he should know, in which category (or tag, term) is paginated. Or he can send a link and who clicked on it knowing for what π If I used mla plugin default links it was targeting to base.cz/. So firstly I created page as subpage photography and insert mla shortcode there. Generally you can say, that I switched/attachment_tag/for/fotografie/tag/because there is a structure easy readable from, and the second,tagslug is more simple thanattachment_tagslug. (I know thattagslug uses WP in but I can rename it if I have to, Im using it as universal not as taxonomy exact – for originaltagslug Im using tΓ©ma which mean topic in english. )I think we wrote about that topic already something.
In future , if I will need use attachment tag even for blog section, I will have remake the code, I now, but it could be a THEME or IDEA for you : show attachment_tag accordingly to which category or parent article is linked. Like, be more structural. Thank you for your readings and have a nice day today π
Ok, thanks. I will take the time tomorow (myabe today its 0:40 am for me now) good night π
Forum: Reviews
In reply to: [Media Library Assistant] Yes! This plugin deserve to be in core of WP !You are fully right, your progress and development on that thing is incredible, so put it in core could be bad for keeping that “piece of golden code” really flexible and actual. I meant “be in core” its honor, but its maybe like put Panda from free forest in zoo π
Thanks for respond.
I will see the sources you gave me. (edit: first I know , second seems giving a clue! )
Meanwhile, Im solving another issue with replacing strings given to the final html via shortcode which is part of a plugin.
So you tell that I can not do upper thing from a theme (if i understand from a function.php in my child theme). So subsequently brings me a question. Is gennerally posible to filter a function which is inside the plugin from function.php in child theme?
Because just now Im parsing shortcode and replacing. It could be much more elegant to do it via filter as filtering main theme.In general, basicly, I always assumed that via functions.php i can do anything in the wordpress… ?
Thanks again for sources !
Forum: Plugins
In reply to: [Media Library Assistant] PaginationSo, challenge accepted. π After day and one coffee night I spend every minute on forums picking up ideas and snippets, editing them and putting together Bringing this, even not ideal because:
I can use nice urls with mla shortcode,
but – old urls still works (they should be redirected to nice)
Here is my results till now:First, if you interested, Im raising from thread rewrite-custom-taxonomy-slug so next code depends on that.
So firstly in htaccess file i created a rule:
RewriteRule ^fotografie/tag/([^/]+)/([^/]+)/?$ http://www.danielkral.cz/fotografie/tag/$1?mla_paginate_current=$2 [NC]– this rewrite query url with nice url, if you will use [R=301,QSA,L] instead shown, be sure that you’ll be redirected – so in url you will see old query adress even if you type nice url.Second in taxonomy-attachment_tag.php file is code:
echo apply_filters( 'thematic_open_id_content', '<div id="content">' . "\n\n" ); $prev_page = do_shortcode( sprintf( '[mla_gallery %1$s="%2$s" mla_output="previous_page" numberposts="7" mla_link_class="prev page-numbers" mla_link_text="<span class=\'meta-nav\'>β</span> PΕedchozΓ"]', $wp_query->query_vars['taxonomy'], $wp_query->query_vars['term'] ) ) ; $next_page = do_shortcode( sprintf( '[mla_gallery %1$s="%2$s" mla_output="next_page" numberposts="7" mla_link_class="next page-numbers" mla_link_text="DalΕ‘Γ <span class=\'meta-nav\'>βΊ</span>"]', $wp_query->query_vars['taxonomy'], $wp_query->query_vars['term'] ) ) ; // displays the page title thematic_page_title(); $url = get_bloginfo('url').parse_url($_SERVER['REQUEST_URI'],PHP_URL_PATH); $ot = ''; if (parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY)) {$ot = '?';} $url_query = $ot. parse_url($_SERVER['REQUEST_URI'],PHP_URL_QUERY); $complt_url =$url . $url_query; // print( 'url: '.$complt_url.'<br> ' ) ; // print( 'query: '.$url_query. '<br>' ) ; $url_arr = explode("/",$url) ; $last = end($url_arr); // print( 'last: '.$last. '<br>' ) ; // print( 'term: '.$wp_query->query_vars['term']. '<br>' ) ; // print( 'while: '.$url_arr. '<br>' ) ; /**/ $rep_url = $url; if ($last != $wp_query->query_vars['term']) { //vypisuje url az po term v url $rep_url = ''; foreach ($url_arr as $value) { if ($value != $wp_query->query_vars['term']){ $rep_url .= $value . '/'; }else break; } $rep_url = $rep_url.$wp_query->query_vars['term']; //print( 'url: '.$complt_url.'<br> ' ) ; //print( 'repurl: '.$rep_url.'<br> ' ) ; } $rep_url_final_prev = preg_replace('/<a(.*)href="([^"]*)mla_paginate_current=(.*)"(.*)>/','<a$1href="'.$rep_url.'/$3"$4>',$prev_page); $rep_url_final_next = preg_replace('/<a(.*)href="([^"]*)mla_paginate_current=(.*)"(.*)>/','<a$1href="'.$rep_url.'/$3"$4>',$next_page);this code parse mla_gallery shortode and replace old query urls to nice urls.
in place where you want use gallery shorcode , in template, put this code:<?php echo $rep_url_final_prev; echo $rep_url_final_next; ?>That should works. Finaly I want to know you that this solution is not as good as is difficult. Your old query links probably will works still and dont know why, the wordpress redirecting rules not giving 404 error page on most things after query string even after nice url.
(put “?mla_paginate_current=4” for example after nice url, if used page number nothing happened but url not redirect, if just after term it works – both states are not ideal)
If anynone could contribute I will be glad.Partially working http://www.danielkral.cz/fotografie/tag/atelier/3 (maybe little different yet because in development still)
Forum: Plugins
In reply to: [Media Library Assistant] rewrite custom taxonomy slug?Thank you. Im interested in good challenges π
Finally I observed, how is important finalizing the forums for future someones use(hook-to-change-custom-tag-taxonomy-links) here, due to someones post, after he solve his issue, I could also have it done. So Im bringing it back in the TOTAL finaly solution in my troubles here:
There are two ways:
First I realized that name of attachment_tag taxonomy as custom taxonomy need not be renamed. Solution is create new custom taxonomy with desired name. But, now im not able to do it because I do not fully understand creating this or subsequently implement that in mla_gallery after. But its not a question for now! Thats my future chalenge.
Consequently foregoing slug fotografie (understand final “fotografie/tag” instead “attachment_tag”) is as we wrote together before more rewrite and WP issue than MLA.Second, and this is important, even if you would not cerate your own custom taxonomy with your desired name you can finaly change the url which tag cloud targetting and for this I use mentioned article, here So finally as I found solution, hope that maybe after years someone be pleased for finalizing threads as I was today.
Thank you for vishing luck and I wish you too. π
Thank you again also for great ability to use {+variable+} in mla shorcode so I was able to do great things like using MLA as generator for multiple images in one theme on one page. Finally everything works together now on my site. (if not currently Im playing with it or improving, so visit later)Forum: Plugins
In reply to: [Media Library Assistant] rewrite custom taxonomy slug?EDIT: Finally working with:
A –RewriteRule ^attachment_tag/([^/]+)/?$ http://www.danielkral.cz/fotografie/tag/$1 [R=301,QSA,L]in htaccess
B – created page TAG in FOTOGRAFIE category in admin area with using taxonomy-attachment_tag.php template.
C1 – using add_rewrite_rule as described here: need-help-with-add-rewrite-rule
C2 – with wp_redirect conditionaly rewrites url “danielkral.cz/fotografie/tag/” to 404 error page because when vistitor could reach it no tag is selected.
D – As i like reach that before I wrote, I dont know how: urls from tag cloud is still tagreting to “danielkral.cz/attachment_tag/” but its handled now with A,B,C …What could be a guide for you, to better understand what I mean is capability WP in admin area in permalinks rename slug tag for whatever.
The second, the added tag in url before “attachment_tag” I fully undernstand that is more generally thing than this plugin thing.So finally thats my temporary solution, maybe for long time, but if you in future will find a cure for make it customizable for such cases, i will be glad, but overall, great plugin !!!
And for last thing mentioned in my previous contribution here is prtscr as it seems. name of image is “nt”. http://oi39.tinypic.com/10zwak6.jpg
Forum: Plugins
In reply to: [Media Library Assistant] rewrite custom taxonomy slug?Thank you.
The code you provide unfortunatelly not works. For latter searchers I made it as:$object = get_queried_object(); if ( isset( $object->taxonomy ) && 'attachment_tag' == $object->taxonomy ) { $term = $object->slug; wp_redirect( site_url( '/fotografie/tag/' . $object->slug ), 301 );This code directly put in taxonomy-attachment_tag.php 301 for rewrite permanently. (didnt forget visit permalinks and save even)
Using only that and created “tag” page as child in “fotografie” for prevent error 404. But still not works…
As I told before I realized that this issue is maybe not plugin question so I dont want spend your time.
Thank you for your time and I will post a solution when I google it and stick it together someway. Maybe I will stay in the solution which I supposed as temporary (as I desrcibe before). I can do that like that but its not much clean, but works… (Im not a kind of programmer even, so hope this sentence does not sounds like Im ungrateful π )Over this I found some strange manner with plugin: When i have some photography name only as
nt.jpgin MLA is this picture shown as attached to abnormally count of posts. I observed that its maybe due to fact thatntstring is appears in many posts… isnt? So maybe it should have had some other detection of placing than where string appears ??? So maybe at least this is the something which helps improve your plugin. π