Jump to content

Recommended Posts

Okay, yeah, wasn't expecting that. Ahem. But the point is, you are working with a lot of HTML. And the right tool for the "working with a lot of HTML" job is DOMDocument.

 

But this WP stuff. Is it from your own site? Because the way to get the HTML output you want would be to do whatever it takes to WP to actually get that output from the start. Don't have to edit it after the fact because it's already correct.

If you want to know how to do it for academic reasons that's one thing, but the solution to the problem is fixing the template so it outputs the HTML you want.

 

So you know where that template is? How to edit it?

no, i don't really know what i'm doing right now in regards to editing the wordpress html. my code is below.

 

 

$fivesdrafts = $wpdb->get_results(
    "SELECT * FROM $wpdb->posts    WHERE id <= 60 && post_type='post' && post_title!='Auto Draft'"
);        

echo '<div class="row">';
foreach ( $fivesdrafts as $fivesdraft )
{
    echo '<div class="col-sm-3"">';
    //echo "<br>".print_r($fivesdraft);
    echo '<h2><a href='.$fivesdraft->post_name.'>'.$fivesdraft->post_title.'</h2>';
    //echo "<br><a href='.$fivesdraft->post_title.'>".$fivesdraft->post_title."</a>";
    echo "<br>".$fivesdraft->post_content;
    echo '</div>';
}
echo '</div>';
?>
 
for some odd reason as soon as i set that h2 tag to become a link, the entire contents of post_content became a link as well.

but the real problem is that i have no way to put multiple posts on my homepage other than doing what I was doing with the wp_get_results function

I don't know WP but I'm pretty sure you're supposed to do it using a loop. "The Loop"? You get the posts you want to show, set up the loop, and inside display the posts like you normally would.

 

and my other problem is that $fivesdrafts->post_content contains an link along with an empty unmarked up text string that needs to be in a paragraph tag

So the post content itself has the problem? Are you doing this to fix the content because it's wrong, or because the content is right but in this particular case you want it to be different?

 

And sorry to ask but can you post that HTML again? I won't be stupid about it this time.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.