none
Retrieve Post Title for Sharing Social Media RRS feed

  • Question

  • Hello,

    how i want to retrieve this title to be used in Sharing Social Media?

    Thank You.

    Friday, January 27, 2017 8:26 AM

Answers

  • Hi,

    We can use JavaScript to get current page title.

    <script src="//code.jquery.com/jquery-3.1.0.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
    	var title=$(document).find("title").text();
    	alert(title);
    });
    </script>

    Or we can also use REST API to get the post title. Then get the page title like (post title+" - "+site name).

    /_api/web/lists/getbytitle('Posts')/items(2)/Title

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, January 30, 2017 2:28 AM
    Moderator
  • Hi,

    We just split the Title like this:

    var title=$(document).find("title").text().split('-')[0];
    

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Ameenah Monday, March 27, 2017 8:18 AM
    Sunday, March 26, 2017 1:31 AM
    Moderator

All replies

  • Hi,

    We can use JavaScript to get current page title.

    <script src="//code.jquery.com/jquery-3.1.0.min.js" type="text/javascript"></script>
    <script type="text/javascript">
    $(function () {
    	var title=$(document).find("title").text();
    	alert(title);
    });
    </script>

    Or we can also use REST API to get the post title. Then get the page title like (post title+" - "+site name).

    /_api/web/lists/getbytitle('Posts')/items(2)/Title

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    Monday, January 30, 2017 2:28 AM
    Moderator
  • Hello Dennis,

    Thank you. I successfully retrieve Post Title. Unfortunately, its include with subsite name.
    How i want to retrieve only Post Title?

    Thank You.

    Tuesday, March 14, 2017 5:36 AM
  • Hello Dennis,

    Thank you. I successfully retrieve Post Title. Unfortunately, its include with subsite name.
    How i want to retrieve only Post Title?

    Thank You.

    Friday, March 24, 2017 1:35 PM
  • Hi,

    We just split the Title like this:

    var title=$(document).find("title").text().split('-')[0];
    

    Best Regards,

    Dennis


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com

    • Marked as answer by Ameenah Monday, March 27, 2017 8:18 AM
    Sunday, March 26, 2017 1:31 AM
    Moderator
  • Thank You so much Dennis.
    Monday, March 27, 2017 8:19 AM