Forum Replies Created

Viewing 15 replies - 31 through 45 (of 45 total)
  • Thread Starter Lrrr

    (@lrrr)

    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^/]+)/?$ https://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 ??

    Thread Starter Lrrr

    (@lrrr)

    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.

    Thread Starter Lrrr

    (@lrrr)

    I 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 https://www.ads-software.com/support/topic/mod_rewrite-htaccess-works-but-ie?replies=1#post-4727521

    Thread Starter Lrrr

    (@lrrr)

    Update: 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. ??

    Thread Starter Lrrr

    (@lrrr)

    David, 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, https://www.danielkral.cz/fotografie/tag/story?mla_paginate_current=$2 would become https://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: https://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, tag slug is more simple than attachment_tag slug. (I know that tag slug uses WP in but I can rename it if I have to, Im using it as universal not as taxonomy exact – for original tag slug 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 ??

    Thread Starter Lrrr

    (@lrrr)

    Ok, thanks. I will take the time tomorow (myabe today its 0:40 am for me now) good night ??

    Thread Starter Lrrr

    (@lrrr)

    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 ??

    Thread Starter Lrrr

    (@lrrr)

    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 !

    Thread Starter Lrrr

    (@lrrr)

    So, 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/([^/]+)/([^/]+)/?$ https://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 https://www.danielkral.cz/fotografie/tag/atelier/3 (maybe little different yet because in development still)

    Thread Starter Lrrr

    (@lrrr)

    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)

    Thread Starter Lrrr

    (@lrrr)

    EDIT: Finally working with:
    A – RewriteRule ^attachment_tag/([^/]+)/?$ https://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”. https://oi39.tinypic.com/10zwak6.jpg

    Thread Starter Lrrr

    (@lrrr)

    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.jpg in MLA is this picture shown as attached to abnormally count of posts. I observed that its maybe due to fact that nt string 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. ??

    Thread Starter Lrrr

    (@lrrr)

    Now Im running like https://wordpress.stackexchange.com/questions/5413/need-help-with-add-rewrite-rule
    I manualy created a page TAG with taxonomy-slug.php template but now working both urls https://www.danielkral.cz/attachment_tag/sexy
    and https://www.danielkral.cz/fotografie/tag/sexy so iM facing to redirect them to second. After I will have to redirect to error page a default manuall created page “tag” which is now working https://www.danielkral.cz/photography/tag and should not be. BUt stil i feel this is not a best way how to do it… it is too awkward , isnt?
    added to in htaacess RewriteRule ^attachment_tag/([^/]+)/?$ https://www.danielkral.cz/fotografie/tag/$1 [R=301,QSA,L] but still hrefs from tag clouds targets to attachment_tag… So Im taking this as temporary solution, NOT CLEAN, anyone?

    consequently i found https://www.danielkral.cz/fotografie/sexy is working becose filename is “sexy” oh no… it is not sexy… grrr
    (for first sample url i gave here: correct is fotografie not photography)

    Thread Starter Lrrr

    (@lrrr)

    further thoughts:
    I do not want create page “tag” as subpage of existing page “fotografie”. It would have an existing url with empty or some default content needed, so it make no sense to me to be clear solution even partial. Is this proper thinking?

    So working as you suggest here: https://www.ads-software.com/support/topic/template-query-for-att-tags?replies=7

    wordpress itself allows to rename slug “tag” in the tag taxonomy (in admin menu) so Im supposing that it could be done similar on custom taxonomies. Even now, Im not sure, how much its your plugin question and how much it is question corresponding with WP matter at all.

    Im not even sure now, if Im asking appropriately concerning your plugin or if I may ask generally – how to filter or hook some wordpress function od maybe directly rewrite it in htaacess (i tried but i thing its not proper way becose one of upper url does not exists- rewriting nice url to another nice url. theres no query).

    found somthing about {$permastruct}_rewrite_rules in wp codex but not explained…

Viewing 15 replies - 31 through 45 (of 45 total)