• 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
    https://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!!

Viewing 10 replies - 1 through 10 (of 10 total)
  • I don’t know, because you’d absolutely have to have other HTML tags to call WordPress and the database.

    Thread Starter paulwordpress

    (@paulwordpress)

    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?

    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.

    Thread Starter paulwordpress

    (@paulwordpress)

    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
    https://www.mysite.com/my_new_page.php?id=33

    and then the title of post #33 to appear.

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

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

    thanks in advance whooami

    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 ??

    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.

    Thread Starter paulwordpress

    (@paulwordpress)

    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 ??

    and why dont you want to use the loop?

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

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

    https://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.

    Thread Starter paulwordpress

    (@paulwordpress)

    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!

    simple ??

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

    Thread Starter paulwordpress

    (@paulwordpress)

    awesome thanks, i’ll give it a whirl

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘echo “the title” without “the Loop”’ is closed to new replies.