• Resolved lassepappa

    (@lassepappa)


    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=’https://www.laplandevent.com/img/wp/partners/&#8221;.$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.

Viewing 4 replies - 1 through 4 (of 4 total)
  • <?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="https://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.

    Thread Starter lassepappa

    (@lassepappa)

    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

    Thread Starter lassepappa

    (@lassepappa)

    Ok i got it working thank you!

    Thread Starter lassepappa

    (@lassepappa)

    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

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘xlanguage with custom fields’ is closed to new replies.