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

  1. paulwordpress
    Posted 9 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

    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
    Posted 9 years ago #

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

  3. paulwordpress
    Posted 9 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
    Posted 9 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
    Posted 9 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

    and then the title of post #33 to appear.

    and if i type

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

    thanks in advance whooami

  6. whooami
    Posted 9 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
    Posted 9 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
    Posted 9 years ago #

    and why dont you want to use the loop?




    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
    Posted 9 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
    Posted 9 years ago #

    simple :)

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

  11. paulwordpress
    Posted 9 years ago #

    awesome thanks, i'll give it a whirl

Topic Closed

This topic has been closed to new replies.

About this Topic