[wp-hackers] $wpdb query

Robin Adrianse shorty114 at shorty114.net
Fri Sep 22 03:06:39 GMT 2006


http://xref.redalt.com/wptrunk/nav.htm?wp-includes/post.php.source.htm#l481

There's a function called wp_insert_post that does all the work for you. It
takes an array with all the post info in it, just make sure to have an entry
in the array with a key post_type = page and post_status = static.

On 9/21/06, ryan fitzer <ryanfitzer at gmail.com> wrote:
>
> >
> > Why not just do all of it in the INSERT query? Unless you have no
> control
> > over that query...
> >
>
> No idea what the syntax for this would be. Just got WP set up on my local
> machine with MAMP and going to get this going. What would you suggest?
>
> Ryan
>
> On 9/20/06, Robin Adrianse <shorty114 at shorty114.net> wrote:
> >
> > Why not just do all of it in the INSERT query? Unless you have no
> control
> > over that query...
> >
> > On 9/19/06, ryan fitzer <ryanfitzer at gmail.com> wrote:
> > >
> > > Cori, thanks. I'll give this a try. Makes sense.
> > > Robin, not a stupid question. I'm placing the query right after the
> > first
> > > page INSERT query. So I'm figuring that the post is setup at this
> point.
> > > Right?
> > > After I get this to work I'll try updating the codex as well as well
> as
> > > adding in the parts about sub-pages and sub-cats.
> > > Thanks again for the help.
> > >
> > > On 9/19/06, Robin Adrianse <shorty114 at shorty114.net> wrote:
> > > >
> > > > Stupid question, but you *have* inserted the post already, right?
> > > >
> > > > Also, as the email after mine suggests, use ID instead of post_ID.
> > > >
> > > > On 9/19/06, ryan fitzer <ryanfitzer at gmail.com> wrote:
> > > > >
> > > > > Thanks for the help. It is the SQL that I'm having trouble with
> but
> > > your
> > > > > explanation helped in other ways. Here is what I've used for a
> > subpage
> > > > > without success:
> > > > >
> > > > > $wpdb->query("UPDATE $wpdb->posts SET post_parent = 3 WHERE
> post_ID
> > =
> > > > > 4 AND post_status = 'static'");
> > > > >
> > > > > Got no results from this. And no clue what the query would look
> like
> > > > with
> > > > > a
> > > > > sub-cat.
> > > > >
> > > > > Ryan
> > > > >
> > > > > On 9/19/06, Robin Adrianse <shorty114 at shorty114.net> wrote:
> > > > > >
> > > > > > Like you said, I'm not sure if this is the best place for a
> > request
> > > > like
> > > > > > this, but here's my answer:
> > > > > >
> > > > > > Categories: A category is made a subcategory by setting
> > > > category_parent
> > > > > to
> > > > > > something other than 0, namely the ID of the category which is
> its
> > > > > parent.
> > > > > > If it is 0, then it will just be handled as a root category (no
> > > > > parents).
> > > > > > If
> > > > > > you can't figure out the SQL for this, feel free to ask.
> > > > > >
> > > > > > Pages: First off, a page is differentiated from a post by the
> > > setting
> > > > of
> > > > > > post_status. Pages always have it set to "static" (without
> quotes,
> > > of
> > > > > > course), and posts can have it published, draft and private.
> That
> > > > said,
> > > > > a
> > > > > > page is made a sub-page similarly to a category. There is a
> field
> > > > > > post_parent which is the ID of the page's parent. If it is 0, it
> > is
> > > a
> > > > > > root-level page.
> > > > > >
> > > > > > I hope this answered your questions.
> > > > > >
> > > > > > On 9/19/06, ryan fitzer <ryanfitzer at gmail.com> wrote:
> > > > > > >
> > > > > > > Tried the forums but I'm not sure if that's the place for it.
> > > > > > >
> > > > > > > Anyone know the query to add a sub-category and a sub-page in
> > > > > > install.php?
> > > > > > > I
> > > > > > > want to be able to use it to do auto set-ups for custom
> themes.
> > > Any
> > > > > help
> > > > > > > would be great.
> > > > > > >
> > > > > > > I'm also trying this for WordPress MU for a different project.
> > > > > > > I've successfully added an extra category, post and page. I'm
> so
> > > > > close!
> > > > > > > Thanks for any help.
> > > > > > > --
> > > > > > > Ryan Fitzer
> > > > > > > _______________________________________________
> > > > > > > wp-hackers mailing list
> > > > > > > wp-hackers at lists.automattic.com
> > > > > > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > > > > > >
> > > > > > _______________________________________________
> > > > > > wp-hackers mailing list
> > > > > > wp-hackers at lists.automattic.com
> > > > > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > > > > >
> > > > >
> > > > >
> > > > >
> > > > > --
> > > > > Ryan Fitzer
> > > > > Dallas, TX
> > > > > http://www.ryanfitzer.com
> > > > > _______________________________________________
> > > > > wp-hackers mailing list
> > > > > wp-hackers at lists.automattic.com
> > > > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > > > >
> > > > _______________________________________________
> > > > wp-hackers mailing list
> > > > wp-hackers at lists.automattic.com
> > > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > > >
> > >
> > >
> > >
> > > --
> > > Ryan Fitzer
> > > Dallas, TX
> > > http://www.ryanfitzer.com
> > > _______________________________________________
> > > wp-hackers mailing list
> > > wp-hackers at lists.automattic.com
> > > http://lists.automattic.com/mailman/listinfo/wp-hackers
> > >
> > _______________________________________________
> > wp-hackers mailing list
> > wp-hackers at lists.automattic.com
> > http://lists.automattic.com/mailman/listinfo/wp-hackers
> >
>
>
>
> --
> Ryan Fitzer
> Dallas, TX
> http://www.ryanfitzer.com
> _______________________________________________
> wp-hackers mailing list
> wp-hackers at lists.automattic.com
> http://lists.automattic.com/mailman/listinfo/wp-hackers
>


More information about the wp-hackers mailing list