Wordpress Themes - WP Forum at BFA

Wordpress Themes - WP Forum at BFA (http://forum.bytesforall.com/index.php)
-   Center area post/pages (http://forum.bytesforall.com/forumdisplay.php?f=32)
-   -   Changing page content dynamically (http://forum.bytesforall.com/showthread.php?t=15239)

chrisrap Aug 29, 2011 04:47 AM

Changing page content dynamically
 
Hi

I'm new to the forum so apologies if I'm posting in the wrong area or asking a silly question :) I have read quite a few forum posts but I can't find an answer to my current problem with Atahualpa 3.6.7 running on WordPress 3.2.1

I have created a custom template (page.php) by copying index.php (pretty standard stuff so far) and I have played around with the content. My problem is that I want to create the entire body content dynamically from a second database, resident on the same MySQL server. I have a block of PHP code that I am including but part of that content creates a WP short-code to position a gallery (tag-gallery) and of course, because this is just being output directly WP isn't processing the code in any way so the short-code just displays on the page.

So, I think I need to put the page content into a variable and then pass this to the WP the_content() function to be processed and output. Is this correct ... and how would I go about doing that within Atahualpa? I'm guessing that I can also rip out a lot of the index.php code in my new page.php because it doesn't have to worry about comments, archives and posts - it just has to display a header and the page content that I create from the other DB.

Anyway, sorry for a long first post - I hope someone can point me in the right direction :)

Thanks, Chris R.

chrisrap Aug 29, 2011 05:12 AM

Apologies for the false alarm ... I think I have found the answer by examining the the_content() function. Seems much easier than I thought it would be but I have copied out the code inside the_content() and just filled $content with my own content generated from the database:

PHP Code:

    $content $chriscontent;
    
$content apply_filters('the_content'$content);
    
$content str_replace(']]>'']]>'$content);
    echo 
$content

Does that sound OK? Or have I made a terrible blunder that will cause problems later on? :)


All times are GMT -6. The time now is 04:30 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.