Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author Greg Winiarski

    (@gwin)

    I am not sure what are “para breaks”?

    Thread Starter garethf

    (@garethf)

    Paragraph breaks – ie. when the information is entered in the form, I hit return to start a new paragraph.

    When it is displayed on the advert details page, it shows as one paragraph without any breaks.

    Plugin Author Greg Winiarski

    (@gwin)

    Hmm WPAdverts should support this, actually it seems to be working fine on the demo site. For example here https://demo.wpadverts.com/advert/little-big-planet-3/ each block of text is in separate <p> tag?

    Thread Starter garethf

    (@garethf)

    Hmmmm, ok, actually I have two problems:

    1. There are no <p> tags in the two fields details and experience when displayed here: https://equity4sweat.com/advert/startup-advisor/

    2. On everyone’s ad except my own, the details are not included in the “Looking For” field – see example ehre where it is not displayed:
    https://equity4sweat.com/advert/business-development/

    The code I used for this in my custom plugin is as follows:

    add_action( "adverts_tpl_single_details", "my_adverts_tpl_single_details" );
    
    /**
         * Displays custom fields on advert details page
    */
    
    function my_adverts_tpl_single_details( $post_id ) {
        $cf = get_post_meta( $post_id, "experience", true);
        $cc = get_post_meta( $post_id, "post_content", false);
    
        ?>
    
        <?php if(! empty($cf) ): ?>
        <div class="adverts-grid-row">
            <div class="adverts-grid-col adverts-col-30">
                <span class="adverts-round-icon adverts-icon-briefcase"></span>
                <span class="adverts-row-title">Experience</span>
            </div>
            <div class="adverts-grid-col adverts-col-65">
                <?php esc_html_e( $cf ) ?>
            </div>
        </div>
        <?php endif; ?>
    
        <?php if(! empty($cc) ): ?>
        <div class="adverts-grid-row">
            <div class="adverts-grid-col adverts-col-30">
                <span class="adverts-round-icon adverts-icon-search"></span>
                <span class="adverts-row-title">Looking For</span>
            </div>
            <div class="adverts-grid-col adverts-col-65">
                <?php esc_html_e( join(", ", $cc) ) ?>
            </div>
        </div>
        <?php endif; ?>
    
        <?php
    }
    Thread Starter garethf

    (@garethf)

    In case you need it, here is where I add the custom field ‘experience’:

    add_filter( "adverts_form_load", "my_adverts_form_load" );
    
    /**
         * Adds custom fields
    */
    
    function my_adverts_form_load( $form ) {
    
        if( $form["name"] != "advert" ) {
            return $form;
        }
    
        $form["field"][] = array(
            "name" => "experience",
            "type" => "adverts_field_textarea",
            "order" => 20,
            "label" => "Previous Experience",
    	"mode" => "tinymce-mini",
            "is_required" => true,
            "validator" => array(
                array( "name" => "is_required" ),
            )
        );    
    
        return $form;
    }

    and here is where I change the name of the details field:

    add_filter( "adverts_form_load", "customize_adverts_add" );
    
    /**
         * Customises default fields
    */
    
    function customize_adverts_add( $form ) {
      if( $form['name'] != "advert" ) {
        return $form;
      }
    
      foreach( $form["field"] as $key => $field ) {
       if( $field["name"] == "post_content" ) {
            $field["label"] = __( "Looking for", "adverts" );
            $form["field"][$key] = $field;
        }
    }
    
      return $form;
    }
    Plugin Author Greg Winiarski

    (@gwin)

    Thecode for custom fields allows only to display plain text, if you want to have HTML paragraphs there then in first snippet replace

    <?php esc_html_e( $cf ) ?>

    with

    <?php echo strip_tags( wpautop( $cf ), "<p>" ) ?>

    Thread Starter garethf

    (@garethf)

    Thanks – that worked for the para breaks issue.

    However, on everyone’s ad except my own, the details are not included in the “Looking For” field – see example here where it is not displayed:

    https://equity4sweat.com/advert/business-development/

    Whereas here (my ad) it is displayed:

    https://equity4sweat.com/advert/startup-advisor/

    Whereas I know from the admin panel that details were included.

    Thread Starter garethf

    (@garethf)

    Ok, for now I solved this by replacing:

    <div class="adverts-content">
        <?php echo $post_content ?>
    </div>

    with:

    <div class="adverts-grid-row">
            <div class="adverts-grid-col adverts-col-30">
                <span class="adverts-round-icon adverts-icon-search"></span>
                <span class="adverts-row-title">Looking For</span>
            </div>
            <div class="adverts-grid-col adverts-col-65">
               <?php echo $post_content ?>
            </div>
        </div>

    in the single.php file but obviously this is not best practice. Would be good to know why this doesn’t work using the code above on anyone’s ads but my own.

    Plugin Author Greg Winiarski

    (@gwin)

    The changes you make in original files will be overwritten on update.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Para breaks in description text’ is closed to new replies.