WordPress.org

Ready to get started?Download WordPress

Forums

echo "the title" without "the Loop" (11 posts)

  1. paulwordpress
    Member
    Posted 7 years ago #

    Hi, i want to create a COMPLETELY NEW php file which ONLY echoes the title of a post onto the page. i don't even want body or html tags on the page.

    so i want a url like
    http://www.mysite.com/my_new_page.php?id=33

    and all i want on that page is the title of post 33

    so if i made a post that has a title called
    "This is post is about magic"

    all i want on the page is
    "This is post is about magic"

    i don't want ANYTHING ELSE.

    how do i do this?

    thank you!!

  2. DianeV
    Member
    Posted 7 years ago #

    I don't know, because you'd absolutely have to have other HTML tags to call WordPress and the database.

  3. paulwordpress
    Member
    Posted 7 years ago #

    html tags are different php tags... i shouldn't need html tags to load the title.

    ignoring that, how would i create a new php file and which only has the title on it?

  4. whooami
    Member
    Posted 7 years ago #

    do you want to update this new page automatically when you make a new post or append to whats already on the page, so like the previous posts titles are still there?

    Both of those arent too terribly hard to do, I just need to know which because the directions are slightly different.

  5. paulwordpress
    Member
    Posted 7 years ago #

    i think the latter.

    i just want to make a new page which i can refer to,
    let's call it my_new_page.php for example

    i just want to be able to type
    http://www.mysite.com/my_new_page.php?id=33

    and then the title of post #33 to appear.

    and if i type
    http://www.mysite.com/my_new_page.php?id=56

    i would like the title of post #56 to appear.

    thanks in advance whooami

  6. whooami
    Member
    Posted 7 years ago #

    a new page within wordpress, ie, a wordpress page, or just any old page? cuz that looks like you want to tack on something -- whats the 33?

    Im sorry, i didnt read.. thats the post ID.

    So you want 2 things then .. not one :P

    you want to tack the numeric id onto the page and grab the title.

    hmm.. im not sure my way will work with the ID, Ill have to test that out when i get up in the morning (im supposed to be asleep).

    Maybe someone more guru-ish then me will come along in the meantime.

    I will need to know though whether or not your wanting to do this with a wordpress page, or just any 'old page. I have NO clue how it would be done with a wordpress page, btw.

  7. paulwordpress
    Member
    Posted 7 years ago #

    yeah, just any ol' page, thanks. 33 is just an example, i want the url to dictate the ID to bring in the title.

    so it could be 33, it could be 56, it could be 12, it could be 101. whatever number is in the url i want that post's title in the page.

    -------------------------------------
    it's for a blog with a bunch of ajax - i'm trying to avoid details because that will just confuse everything
    -------------------------------------
    thanks a bunch whooami. have a nice rest :)

  8. whooami
    Member
    Posted 7 years ago #

    and why dont you want to use the loop?

    http://www.village-idiot.org/my-title.php?p=20

    http://www.village-idiot.org/my-title.php?p=200

    http://www.village-idiot.org/my-title.php?p=817

    because THAT really simplifies matters ...

    the way I would do it without having the simplicity of the loop is write to a file with all the post ids, and titles. I do that right now to advertise my most recent post. (I hook into wp-admin/post.php and write to the file with every new post.) I dont append to the file but thats an easy enough change.

    Then.. once you had the file generated, you could use php magic to search the file via the post id, and display the title.

    That seems like a lot of work though for what you want.

  9. paulwordpress
    Member
    Posted 7 years ago #

    oh, those links are exactly what i need.

    what is the code for that?

    because i am having trouble transferring the id from the url to the page.

    i just want the really simple version. as long as the id in the url brings that title in, i would be over the moon.

    thank you!

  10. whooami
    Member
    Posted 7 years ago #

    simple :)

    <?php require('./wp-blog-header.php');
    if (have_posts()) : while (have_posts()) : the_post();
    the_title();
    endwhile; else:
    endif; ?>

  11. paulwordpress
    Member
    Posted 7 years ago #

    awesome thanks, i'll give it a whirl

Topic Closed

This topic has been closed to new replies.

About this Topic