The MU forums have moved to WordPress.org

Hijacking the have_posts() function (2 posts)

  1. grandslambert
    Member
    Posted 15 years ago #

    Maybe the word "hijacking" isn't the right word, but here is what I am trying to do:

    We are using MU as an Intranet where each manager will have their own blog to post into, from the store manager all the way up to the Area President. There will be in th range of 2K to 3K blogs based on the area. Each blog post is "tagged" with information on who will be allowed to read those posts. This way, the Area President can post something that only Store managers can read, and post something else that everyone can read.

    My current solution to this is to use Donncha's site wide tags widget to create a tags blog, and that is working perfectly on my prototype. But here comes the tough part:

    I do NOT want to display the posts in a sidebar widget, nor do I want to link the posts to the original blog. What I want to do is grab posts from the "tags" blog, filter the messages so the end user sees only what is "tagged" for them to see (i.e. employees don't see manager posts), then display them on the main blog. However, the links CAN NOT go to the actual posts on the blogs, they have to be displayed within the main blog, so I have to "hijack" other functions as well. Note: there will be NO posts made on the main blog.

    I realize to do this I will have to write new functiosn for have_posts() and the_post() and possibly others. I will also need to write custom methods for querying the database - all of which I know how to do. The question is, if I just place the new functions in the functions.php file of my theme, will that work - because it doesn't seem to.

    As a side note, I want to allow comments on all posts. I am not sure if I should write code to store the comments in A) the main blog, B) the tags blog or C) the posts blog. Any suggestions?

  2. grandslambert
    Member
    Posted 15 years ago #

    Before you ask, the error I get in my error_log when I place the have_posts() function of course is:

    Cannont redeclare have_posts() (previsouly declared in /var/www/html/mu/wp-includes/query.php:608)

    I have seen themes place a copy of the "query.php" file in their theme folder, which isn't ideal because I don't want to have to update it each time something changes in the core file.

    So, I am going to try writing my own functions to get posts, then call that function in the post loop. Was hoping to do it another way, but will try this approach unless I hear some other way to do what I want to do.

About this Topic

  • Started 15 years ago by grandslambert
  • Latest reply from grandslambert