Absolute beginner question: I need to load text into specific div tags across the page. On my html mockup its a lorem ispum text box waiting for wordpress to load the real content. So, how do i control the real content and its relation with the div box text on the page? Can it be a post, so i can manage it from the dashboard? Thanks in advance.


You can solve this in different ways.

One it's to use simple querys with WP_Query and using the p parameter to retrive a particular post like it's explained here. Something like this:

$the_query = new WP_Query( 'p=123' );
while ( $the_query->have_posts() ) : $the_query->the_post();

Where 123 it's the post id from where you need the data (the_content).

Or you can query the content from a single post using get_post function. Like this:

$postid = 123;
$queryp = get_post($postid);
$content = $queryp->post_content;
$content = apply_filters('the_content', $content);
$content = str_replace(']]>', ']]>', $content);
echo $content;

Where 123, again, it's the postid from where you need to extract the content.

And i think wp_get_single_post function should work too.

Then you can control your content everywhere just extracting the desired data from certains posts by postid

  • Thanks for the quick reply, TCattd. I'm not sure about where to put the code(which page, which part) but I'll give it a try. Thx again. – luprates Mar 12 '12 at 15:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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