0

The following code allows me to display the post TITLE and content fine, but the content is not displaying as I see it on POST EDITOR.

Here's the webpage where the PHP is rendered: http://queridas.com.ar/sandbox/reflexion/entrevistas/

Here's the PHP code:

<?php

$post_id = 2292;  // Define the ID of the page
$queriedPost = get_post($post_id);  // Load contents of the page
$field_contents = get_post_meta($queriedPost->ID, $field_slug, true);    // Load the contents of the custom field
$post_object = get_post( $post_id );

echo '<h3>' . $queriedPost->post_title . '</h3>';
echo $post_object->post_content;

?>

And here's the post itself: http://queridas.com.ar/sandbox/2017/11/27/la-maternidad-es-una-carcel/

So, how can I use this PHP code with the style that my end-users use? I can't have them edit the code and include

tags, for example. Well... I could, but then again......

Thanks so much!

1 Answer 1

0

First, be sure that you text, in the editor, don't have any code from where you are copying it. Use the HTML tab to check that. In the link you provided, the text has paragraph, with span inside, with more span inside that span. Is kinda weird.

Beside that, you have to use CSS to style every detail of the text, like to 'foresee' what the user will use. Create style for paragraph, headers, span, bold, italic, whatever you need.

6
  • Thanks! I'm using TinyMCE for post editing.. when ever I choose, for exmaple, a font, it creates automatically a <span> tag... do you have any suggestions as how I can do what you say? Maybe use a different editor? Thanks so much! Commented Nov 27, 2017 at 20:33
  • TinyMCE is the best one I know to add extra functions to the editor box. If you really need to use it, and it indeed creates those extra 'span', you still need to define your own styles with CSS to make sure everything works the way it should. You should define the <p> line-height and such so it looks good. Commented Nov 27, 2017 at 20:46
  • you mean define this from the "text/html" view on TinyMCE? or somewhere in the backend? my idea is to make it as easy for the end-user as possible.. they know nothing about code and I wouldn't want them to have to edit CSS in future posts. Thanks so much for your time! Commented Nov 27, 2017 at 21:32
  • I mean, you, the developer, define the properties via css. Because in the end, you just need to style the line-height of paragraphs and headers, as far as I know, TinyMCE can handle the rest. You just need to tweak little things to make it work correctly Commented Nov 27, 2017 at 21:40
  • Hi brother, thanks so much, I finally got it working and it looks awesome :D Have one more question.. this is the PHP code I ended up with: [code]<?php $post_id = 2292; // Define the ID of the page $queriedPost = get_post($post_id); // Load contents of the page $field_contents = get_post_meta($queriedPost->ID, $field_slug, true); // Load the contents of the custom field $post_object = get_post( $post_id ); echo $post_object->post_content; ?>[/code] Now, how can I display the COMMENTS portion? So people can see or leave a comment? Thanks so much! Commented Nov 30, 2017 at 19:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.