Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › need help with php for wordpress regarding echo wpautop
New Posts  All Forums:Forum Nav:

need help with php for wordpress regarding echo wpautop

post #1 of 3
Thread Starter 
For some reason, ocn cuts the code i paste so here is a link to the question i posted in wordpress forum
http://wordpress.org/support/topic/how-to-add-line-breaks-for-post-custom-fields


they work fine except the text I put in the custom field doesnt have spacing or line breaks when I press "enter key" or even when I put
or ;nbsp

I googled and found that the code needed is " echo wpautop " but where do I put it?
Edited by edalbkrad - 8/30/12 at 12:34am
Rabasu i7-3770K
(13 items)
 
Rabasu FX6100
(13 items)
 
 
CPUMotherboardGraphicsRAM
i7 3770K ECS H77H2-M3 MSI RX 580 Armor 8GB OC 2x8GB Kingston HyperX Blu 
Hard DriveHard DriveOptical DriveCooling
Seagate 1TB Seagate 1TB Sony DVDRW stock 
OSMonitorPowerCase
Windows 7 x64 BenQ E2220 1080p Seasonic M12II Evo 620W Coolermaster Elite 430 
Mouse
A4tech X7 710BH 
CPUMotherboardGraphicsRAM
AMD FX 6100 4.0 Ghz 6-core Asus M5A78L-MLX3 AM3+ Powercolor HD7730 1GB DDR5 16GB (2x8GB) Corsair Vengeance LP 1600 
Hard DriveHard DriveOptical DriveCooling
Seagate 1TB Seagate 1TB Sony DVDRW CoolerMaster Hyper212+ with 2x140mm Deepcool UF140 
OSMonitorPowerCase
Windows 7 x64 / Mint x64 BenQ E2220 1080p Aerocool Strike-X 500watts CoolerMaster Elite 430 
Mouse
A4tech X7 710BH 
CPUGraphicsRAMHard Drive
A8 7410 2.5Ghz Radeon R5 M335 2GB 4GB DDR3L 1 TB HDD 
OSCase
Windows 8.1 Dell Inspiron 5455 
  hide details  
Reply
Rabasu i7-3770K
(13 items)
 
Rabasu FX6100
(13 items)
 
 
CPUMotherboardGraphicsRAM
i7 3770K ECS H77H2-M3 MSI RX 580 Armor 8GB OC 2x8GB Kingston HyperX Blu 
Hard DriveHard DriveOptical DriveCooling
Seagate 1TB Seagate 1TB Sony DVDRW stock 
OSMonitorPowerCase
Windows 7 x64 BenQ E2220 1080p Seasonic M12II Evo 620W Coolermaster Elite 430 
Mouse
A4tech X7 710BH 
CPUMotherboardGraphicsRAM
AMD FX 6100 4.0 Ghz 6-core Asus M5A78L-MLX3 AM3+ Powercolor HD7730 1GB DDR5 16GB (2x8GB) Corsair Vengeance LP 1600 
Hard DriveHard DriveOptical DriveCooling
Seagate 1TB Seagate 1TB Sony DVDRW CoolerMaster Hyper212+ with 2x140mm Deepcool UF140 
OSMonitorPowerCase
Windows 7 x64 / Mint x64 BenQ E2220 1080p Aerocool Strike-X 500watts CoolerMaster Elite 430 
Mouse
A4tech X7 710BH 
CPUGraphicsRAMHard Drive
A8 7410 2.5Ghz Radeon R5 M335 2GB 4GB DDR3L 1 TB HDD 
OSCase
Windows 8.1 Dell Inspiron 5455 
  hide details  
Reply
post #2 of 3
Maybe the code is cut because you need to use the CODE tags.
Here:
Code:
<?php } else { echo get_post_meta($transaction_childdeal->post_id,'voucher_text',true); }} ?></p>
        <p class="shipping_address">
        <?php { echo get_post_meta($transaction_childdeal->post_id,'inclusions',true); } ?></p>
        <p class="shipping_address">
        <?php { echo get_post_meta($transaction_childdeal->post_id,'conditions',true); } ?></p>

I had your exact problem recently. When you press return, the commands that are sent to the textbox (even though you can't see them) are LF, LINE FEED and CR, CARRIAGE RETURN, also known as \n and \r respectively (at least in php language).
You need therefore to substitute these symbols with an html tag, the well known br.

This should do it:
Code:
echo str_replace('\r\n','<br />',get_post_meta($transaction_childdeal->post_id,'conditions',true));

Let me know if it works

EDIT: I had a look into that wpautop. I don't usually work with WordPress but this function is basically the same as mine, except this breaks the lines into paragraphs. Check the instructions here.
You can use the same code:
Code:
echo wpautop(get_post_meta($transaction_childdeal->post_id,'conditions',true), 1);

You can use both of them at will.
Edited by d3viliz3d - 8/30/12 at 7:36am
post #3 of 3
Thread Starter 
ill try your suggestion, in the mean time Instead of fixing it, i added more custom fields so ill just put each sentence/line on a new field lol
Rabasu i7-3770K
(13 items)
 
Rabasu FX6100
(13 items)
 
 
CPUMotherboardGraphicsRAM
i7 3770K ECS H77H2-M3 MSI RX 580 Armor 8GB OC 2x8GB Kingston HyperX Blu 
Hard DriveHard DriveOptical DriveCooling
Seagate 1TB Seagate 1TB Sony DVDRW stock 
OSMonitorPowerCase
Windows 7 x64 BenQ E2220 1080p Seasonic M12II Evo 620W Coolermaster Elite 430 
Mouse
A4tech X7 710BH 
CPUMotherboardGraphicsRAM
AMD FX 6100 4.0 Ghz 6-core Asus M5A78L-MLX3 AM3+ Powercolor HD7730 1GB DDR5 16GB (2x8GB) Corsair Vengeance LP 1600 
Hard DriveHard DriveOptical DriveCooling
Seagate 1TB Seagate 1TB Sony DVDRW CoolerMaster Hyper212+ with 2x140mm Deepcool UF140 
OSMonitorPowerCase
Windows 7 x64 / Mint x64 BenQ E2220 1080p Aerocool Strike-X 500watts CoolerMaster Elite 430 
Mouse
A4tech X7 710BH 
CPUGraphicsRAMHard Drive
A8 7410 2.5Ghz Radeon R5 M335 2GB 4GB DDR3L 1 TB HDD 
OSCase
Windows 8.1 Dell Inspiron 5455 
  hide details  
Reply
Rabasu i7-3770K
(13 items)
 
Rabasu FX6100
(13 items)
 
 
CPUMotherboardGraphicsRAM
i7 3770K ECS H77H2-M3 MSI RX 580 Armor 8GB OC 2x8GB Kingston HyperX Blu 
Hard DriveHard DriveOptical DriveCooling
Seagate 1TB Seagate 1TB Sony DVDRW stock 
OSMonitorPowerCase
Windows 7 x64 BenQ E2220 1080p Seasonic M12II Evo 620W Coolermaster Elite 430 
Mouse
A4tech X7 710BH 
CPUMotherboardGraphicsRAM
AMD FX 6100 4.0 Ghz 6-core Asus M5A78L-MLX3 AM3+ Powercolor HD7730 1GB DDR5 16GB (2x8GB) Corsair Vengeance LP 1600 
Hard DriveHard DriveOptical DriveCooling
Seagate 1TB Seagate 1TB Sony DVDRW CoolerMaster Hyper212+ with 2x140mm Deepcool UF140 
OSMonitorPowerCase
Windows 7 x64 / Mint x64 BenQ E2220 1080p Aerocool Strike-X 500watts CoolerMaster Elite 430 
Mouse
A4tech X7 710BH 
CPUGraphicsRAMHard Drive
A8 7410 2.5Ghz Radeon R5 M335 2GB 4GB DDR3L 1 TB HDD 
OSCase
Windows 8.1 Dell Inspiron 5455 
  hide details  
Reply
New Posts  All Forums:Forum Nav:
  Return Home
  Back to Forum: Web Coding
Overclock.net › Forums › Software, Programming and Coding › Coding and Programming › Web Coding › need help with php for wordpress regarding echo wpautop