php - Break a WordPress post on paragraph tags -
i have site 2 databases. 1 attached wordpress install runs part of content of site; other runs site overall. let's call them cwordpress , tdasite.
i have figured out how access wordpress database , pull content it, i'm not sure how break down on p tags, because i'm pulling post_content file. need display text in sidebar, , readability it's nice have in actual paragraphs. articles i'm pulling short, there 3 5 paragraphs in each.
i'm not seeing how wordpress saves formatting. does, since wordpress pages display appropriately, , tags show in view source, they're not visible in database. otherwise, i'd use explode break them paragraphs , display them way. far, can't turn post_content object variable , print it! i'm trying possible, or need reconcept?
this query code.
//define query retrieve international news posts $newsquery = 'select wp_posts.post_title, wp_posts.id, wp_posts.post_content wp_posts, wp_term_relationships, wp_term_taxonomy wp_posts.id=wp_term_relationships.object_id , wp_term_relationships.term_taxonomy_id=wp_term_taxonomy.term_taxonomy_id , wp_term_taxonomy.taxonomy="category" , wp_term_taxonomy.term_id=5 order wp_posts.post_date desc limit 1'; if($r = mysqli_query($dbc, $newsquery)) { // run query. while ($row = mysqli_fetch_array($r)) { echo '<h3 class="betterheader" align="center">' . $row['post_title'] . '</h3><p class="sidebartext">' . $row['post_content'] . '</p>'; } } else { echo '<p style="color: red;">no international news today!</p>'; } ?>
that return post giant block of text, when try declare post_content variable , display it, nothing turns up, makes me think can't handle post way want to. , reference, doing that:
$wppost = $row['post_title']; echo $wppost
to answer question (what i'm trying possible, or need reconcept?), sir html tags defined in page/post templates, , not included in database values.
my suggestion install wordpress php-executor plugin work sidebar widgets, create text widget , put php code-for-content there. suggest using built-in functions get_the_title , get_the_content, , apply proper arguments if want them dynamic.
Comments
Post a Comment