Love Fuel?    Donate

FuelPHP Forums

Ask your question about FuelPHP in the appropriate forum, or help others by answering their questions.
FuelPHP and Wordpress
  • Hi,

    I want to integrate Wordpress in my site (fuelphp).

    I can push the "wordpress" folder in "public", and access with url mysite.com/wordpress, it's work, but i want to use Fuelphp function in my wordpress frontend, and wordpress function in my fuelphp frontend..
    For example : Keep the same layout (construct with fuelph), the same menu (construct with fuelphp), etc.

    What is the best way ?

    Maybe create an other front controller for wp ? Like Controller_Blog which extends Controller_Hybrid, and include WP librairies in the before() function ?
  • I think that will become a hopeless and complex mess...
  • Hmm ok. And if i want to just create a theme for wordpress. And in this theme, i want to use existing views from fuelphp (like header, menu, sidebar, etc..), it's possible ?
  • I think it's work, thanks !

    What i have do : 

    1. index.php, at the top of the file :
    <pre>
    define('WP_USE_THEMES', false);
    require_once("./wordpress/wp-config.php");
    $wp->init(); $wp->parse_request(); $wp->query_posts();
    $wp->register_globals(); $wp->send_headers();
    </pre>

    2. I have create a new controller named "news", with a new theme template and index action

    3. In my new template (themes/default/templates/wordpress.php) i have copied this code :

    <code>
    <?php
    $template = false;
    if     ( is_404()            && $template = get_404_template()            ) :
    elseif ( is_search()         && $template = get_search_template()         ) :
    elseif ( is_tax()            && $template = get_taxonomy_template()       ) :
    elseif ( is_front_page()     && $template = get_front_page_template()     ) :
    elseif ( is_home()           && $template = get_home_template()           ) :
    elseif ( is_attachment()     && $template = get_attachment_template()     ) :
    remove_filter('the_content', 'prepend_attachment');
    elseif ( is_single()         && $template = get_single_template()         ) :
    elseif ( is_page()           && $template = get_page_template()           ) :
    elseif ( is_category()       && $template = get_category_template()       ) :
    elseif ( is_tag()            && $template = get_tag_template()            ) :
    elseif ( is_author()         && $template = get_author_template()         ) :
    elseif ( is_date()           && $template = get_date_template()           ) :
    elseif ( is_archive()        && $template = get_archive_template()        ) :
    elseif ( is_comments_popup() && $template = get_comments_popup_template() ) :
    elseif ( is_paged()          && $template = get_paged_template()          ) :
    else :
    $template = get_index_template();
    endif;
            
    if ( $template = apply_filters( 'template_include', $template ) )
    include( $template );
    ?>
    </code>

    It's include the wordpress theme

    4. I have create a new route for redirect all request in the index action

    <pre>
        'news(/:any)' => 'news/index', // The wordpress route
    </pre>

    Now i access on my wordpress blog with fuelphp via "mysite.com/news" (my wordpress folder is named "wordpress"). And i can use Fuelphp functions and forge view in my wordpress theme !

    The problem : I can always access to my wordpress blog without fuelphp via "mysite.com/wordpress". How i can disabled this ? But i want to always access "mysite.com/wordpress/wp-admin" for backend.
  • Use a rewrite in your .htaccess to block access to the WP frontend?
  • Hm yes, I had not thought. Thanks

    And sorry for the previous post, i don't know how to insert code..
  • I usually create a sub-domain if I need to integrate wordpress or some other system. So if my site is http://mysite.com then I put WordPress to http://blog.mysite.com, but I try to avoid mixing two systems as much as possible because you can ran into all sorts of problems.
  • Sure, but if you need to keep the same layout between your fuelphp theme and wordpress, what do you do? You create the same theme for wordpress? This is not great... 

    If you mix fuelphp and wordpress, you can use View::forge for use your fuelphp theme in your wordpress theme for example.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion