-2

How do i make the tittle of post to appear instead of the tittle of page in php site I have tried putting the php code that pops the tittle of the post but it dint work

3
  • Posts and pages are different entities, what do you mean? If you are in a page it has its own title, if in a post again its own title... Aug 8, 2018 at 12:57
  • 1
    Could you please provide some more context to explain the issue, and maybe snippets of the code you are using? This will make it easier for others to spot what is wrong and to be able to answer.
    – Iceable
    Aug 8, 2018 at 13:00
  • If i share a post from my blog the tittle of the page displays instead of the tittle of the post something like this. welcome to my blog is the tittle of the single.php page. When i share a post it shows welcome to my blog as the tittle of the post instead of the actual tittle. Aug 8, 2018 at 16:37

1 Answer 1

0

To display post title, you could use:

<a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>

or alternately, a simple:

<?php echo get_the_title(post->$ID); ?> 
4
  • Where should i place this code at the top of the page or anywhere? Aug 8, 2018 at 16:49
  • That depends entirely on where you want it to be visible.
    – bulldog
    Aug 8, 2018 at 17:34
  • If you want it to be in browser title bar, then it would go in the <header> section. If you want it in be visible in the page content, then it would appear as a <h1> or <h2> in the content area.
    – bulldog
    Aug 8, 2018 at 17:36
  • i did that but it did not work i want the post tittle to be in the browser tittle bar <img src="<?php echo GW_UPLOADPATH.$get['post_image']; ?>" class="img-responsive" alt=""> <div class="b-bottom"> <h5 class="top"><?php echo $get['title_of_post']; ?></h5> <p class="sub"><?php echo $get['post_writeup']; ?></p> Aug 10, 2018 at 5:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.