Divi WordPress Theme
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

WordPress fix Reply To: while() and newline (\n), how does it make sense?

Discussion in 'Misc WordPress Requests' started by TheDani, Mar 24, 2018.

  1. TheDani

    Guest

    Reply To: while() and newline (\n), how does it make sense?, by TheDani

    Hey,

    WordPress, Pods Admin, Manage Pods, Page:
    Activities
    Label: Activities
    Name: activities
    Field Type: Relationship
    Relates: Activities

    Activities Label
    Label: Activities Label
    Name: activities_label
    Field Type: Plain Paragraph Text
    Output options: empty

    //source single-tmpl.php

    $activities = get_post_meta(get_the_ID(), "activities", false);
    $ids = array_column($activities, 'ID');
    $activities_label = get_post_meta(get_the_id(), 'activities_label', true);

    $args = array(
    'post_type' => 'activity',
    'posts_per_page'=>'-1',
    'post__in' => $ids,
    'orderby' => 'post__in',
    );
    $query = new WP_Query($args);
    while($query->have_posts()) :
    $query->the_post();
    echo "<br>".get_the_title();

    //$activities_label = preg_replace('/^(.+)(\s*)$/m', '<li>$1</li>', $activities_label);
    if (strpos($activities_label, "\n") !== false || false !== strstr($activities_label, PHP_EOL)) {
    echo "<br>".$activities_label."<br><br>";
    }
    endwhile;

    View:

    Bad Karma
    300-600|Bad Karma 200 400|Rose

    Blue Elephant
    300-600|Bad Karma 200 400|Rose

    Rose
    300-600|Bad Karma 200 400|Rose


    I have lot of different php views (up), but no one as these (down)

    Bad Karma
    300-600|Bad Karma

    Blue Elephant
    200

    Rose
    400|Rose

    Reply To: while() and newline (\n), how does it make sense?
     
    #1

Share This Page

Monarch Social Sharing Plugin