WordPress.org

Forums

[Plugin: WP-Paginate] Pagination links with qTranslate (5 posts)

  1. Mortus
    Member
    Posted 3 years ago #

    I'm using qTranslate plugin to maintain several languages on my blog and I found out that WP-Paginate produces pagination links without 'localized' part. For example:
    Default language page 2 URL: http://some.site/page/2/
    English language page 2 URL should be: http://some.site/en/page/2/

    This is just an example, qTranslate could generate different form URLs for alternate languages, but this does not matter for WP-Paginate plugin, all author needs to do is to add following code at the end of wp-paginate.php:

    if(function_exists('qtrans_convertURL')) : add_filter('get_pagenum_link', 'qtrans_convertURL'); endif;

    If qTranslate is used then all the page links in alternate language will have proper localization part, if not - nothing will change.

    I've added this code to wp-paginate.php on my site and it works like a charm.

    http://wordpress.org/extend/plugins/wp-paginate/

  2. Eric Martin
    Member
    Posted 3 years ago #

    I'm assuming that the qTranslate plugin already has a filter for get_pagenum_link, right?

    If so, since WP-Paginate uses get_pagenum_link, wouldn't it already work as long as the qTranslate plugin was enabled?

  3. Mortus
    Member
    Posted 3 years ago #

    Eric, qTranslate has no such filter, unfortunately.

    Actually I didn't know that get_pagenum_link() was WP function, thought it was your :) Maybe it would be better to contact qTranslate's author then, thanks for pointing out.

  4. Eric Martin
    Member
    Posted 3 years ago #

    You are correct, contacting the qTranslate author is the way to get this correctly supported.

    Otherwise every plugin that uses get_pagenum_link() would need to add the code you suggested ;)

  5. ommunist
    Member
    Posted 3 years ago #

    I used the following to enable pagination support with qTranslate
    by using wp_link_pages ( ) function for 2 languages (Russian and English in this example)

    Modify 'entry' in page.php of your Theme:


    <div class="entry">
    <?php the_content('<p class="serif">Read the rest of this page »</p>'); ?>

    <?php $lang = qtrans_getLanguage();
    if ($lang=="ru")
    wp_link_pages(array('before' => '<p>Страницы: ', 'pagelink' => '[ % ]', 'after' => '</p>', 'next_or_number' => 'number'));
    else if ($lang=="en")
    wp_link_pages(array('before' => '<p>Pages: ','pagelink' => '[ % ]', 'after' => '</p>', 'next_or_number' => 'number'));?>

    </div>

Topic Closed

This topic has been closed to new replies.

About this Topic