Forums

[resolved] xlanguage with custom fields (5 posts)

  1. lassepappa
    Member
    Posted 10 months ago #

    Hello!

    Please help me with this xlanguage/custom fields problem!

    Im using custom fields to output a list of partners for a site and i cant seem to get xlanguage to work on the array of custom fields.

    this is the code i use to output the custom fields:

    <div id="partners">
    <?php
    $partners['partners'] = get_post_meta($post->ID,'partner',false);
    $partners['link'] = get_post_meta($post->ID,'partner_link',false);
    $partners['logo'] = get_post_meta($post->ID,'partner_logo',false);
    $partners['description'] = get_post_meta($post->ID,'partner_description',false);
    $ref =& $partners['partners'];
    $i="0";
    foreach ($ref as $value) {
    echo "<div class='partners_rubrik'><h3>$value</h3>
    <img alt='".$partners['logo'][$i]."' src='http://www.laplandevent.com/img/wp/partners/".$partners['logo'][$i]."'>".$partners['description'][$i]."</div>";
    $i++;
    }
    ?>

    </div>`
    the code works and out puts all the custom fields but unfortunately xlanguage does not understand the language tags <span lang="xx"></span> so it outputs both languages (xlanguage works perfectly on all other patrs of the site).
    i found a sollution to custom fields using:`
    $partners = apply_filters('the_title',get_post_meta($post->ID,$partner,true));`
    However this only works with single values and not array.

    Please help!!!
    I cant find anything of use on this topic anywhere.

  2. 10fingers
    Member
    Posted 10 months ago #

    <?php foreach ($ref as $value): ?>
        <div class='partners_rubrik'>
            <h3><?php echo apply_filters('the_title', $value) ?></h3>
            <img alt="<?php apply_filters('the_title', $partners['logo'][$i]) ?>"
                src="http://www.laplandevent.com/img/wp/partners/<?php $partners['logo'][$i] ?>"><?php apply_filters('the_title', $partners['description'][$i]) ?>
        </div>
    <?php $i++; endforeach; ?>

    All you need is to choose right filter for your piece of content (logo, title, description) and call apply_filters() everywhere you need it.

  3. lassepappa
    Member
    Posted 10 months ago #

    Hello again i really dont get this filters part i still get output of two languages.

    should i replace the_title with something?

    <?php echo apply_filters('the_title', $partners['description'][$i]) ?>

    please help

  4. lassepappa
    Member
    Posted 10 months ago #

    Ok i got it working thank you!

  5. lassepappa
    Member
    Posted 10 months ago #

    If someone could still explain the filters for me since i dont really know why its working and how to choose filters I would be greatful

    Lasse

Reply

You must log in to post.

About this Topic