I have a page in WordPress which displays different content depending on the value of a query string see below

http://www.my-site.com/my-page/?id=123

My problem is that this the </code> and <code><br /> <h1></code> tags get set to the value for <code>my-page</code> and not to the value associated to the content for <code>id=123</code></p> <p>I’ve wrote some javascript to dynamically update these elements but there is a 1-2 second lag, plus if I generate an xml file, the outputted file picks up the original <code>my-page</code> title.</p> <p>I’ve also explored the idea of modifying the WordPress function <code>wp_title()</code> but I’m pretty sure that doing this will eventually be overwrote when I upgrade WordPress.</p> <p>What I need really is a way to somehow dynamically set the page title just after it is retrieved but before the function <code>wp_title()</code> is called, any ideas would be great.</p> <p>Read more here: <a href="http://stackoverflow.com/questions/43913294/wordpress-modify-title-value-before-header-is-rendered" target="_blank" title="WordPress - Modify Title value before Header is rendered" rel="nofollow">WordPress – Modify Title value before Header is rendered</a></p> <center><table align="center"> <tr><td> <script type="text/javascript"><!-- google_ad_client = "ca-pub-9166932973222694"; /* 250x250 */ google_ad_slot = "5821781996"; google_ad_width = 250; google_ad_height = 250; //--> </script> <script type="text/javascript" src="//pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </td><td style="padding-left:10px;"> <script type="text/javascript"><!-- google_ad_client = "ca-pub-9166932973222694"; /* 250x250 */ google_ad_slot = "5821781996"; google_ad_width = 250; google_ad_height = 250; //--> </script> <script type="text/javascript" src="//pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </td></tr></table> </center> <br /> <div style="padding:10px;background:#CDCECF;"> <h3>Solution:</h3> If you know the solution of this issue, please leave us a reply in Comment section, to update the question. </div> <br /> <br /> <h3>Wordpress related questions and answers:</h3> <div class="clear"></div> </div> </div> <div id="comments" class="post-box-wrapper"> <div class="post-box"> <!-- You can start editing here. --> <!-- If comments are open, but there are no comments. --> <div id="respond"> <h5>Leave A Response</h5> <p class="cancel-comment-reply"><a rel="nofollow" id="cancel-comment-reply-link" href="/wordpress-modify-title-value-before-header-is-rendered/#respond" style="display:none;">Click here to cancel reply.</a></p> <form action="http://wordpressrelated.com/wp-comments-post.php" method="post"> <div id="comment-input"> <label for="author">Name <span class="req">(required)</span></label> <input type="text" name="author" id="author" value="" size="22" tabindex="1" aria-required='true' class="input-name" /> <label for="email">Email <span class="req">(required)</span></label> <input type="text" name="email" id="email" value="" size="22" tabindex="2" aria-required='true' class="input-email" /> <label for="url">Website</label> <input type="text" name="url" id="url" value="" size="22" tabindex="3" class="input-website" /> </div> <div id="comment-textarea"> <label for="comment">Comment</label> <textarea name="comment" id="comment" cols="39" rows="4" tabindex="4" class="textarea-comment"></textarea> </div> <div id="comment-submit"> <p><input name="submit" type="submit" id="submit" tabindex="5" value="Post Comment" class="comment-submit" /></p> <input type='hidden' name='comment_post_ID' value='145776' id='comment_post_ID' /> <input type='hidden' name='comment_parent' id='comment_parent' value='0' /> <p style="display: none;"><input type="hidden" id="akismet_comment_nonce" name="akismet_comment_nonce" value="b920d09e56" /></p><p style="display: none;"><input type="hidden" id="ak_js" name="ak_js" value="200"/></p> </div> </form> </div> </div> </div> </div> </div> <div id="sidebar"> <div class="widget"><form method="get" id="searchform" action="http://wordpressrelated.com/"> <input type="text" class="search-field" name="s" id="s"> <input type="submit" value="Search" class="search-button"> </form></div><div class="widget"> <div class="textwidget"><script async src="//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js"></script> <!-- 250x250 --> <ins class="adsbygoogle" style="display:inline-block;width:250px;height:250px" data-ad-client="ca-pub-9166932973222694" data-ad-slot="5821781996"></ins> <script> (adsbygoogle = window.adsbygoogle || []).push({}); </script></div> </div><div class="widget"><h4>Categories</h4> <ul> <li class="cat-item cat-item-36"><a href="http://wordpressrelated.com/category/wordpress-htaccess/" title="Wordpress .htaccess">Wordpress .htaccess</a> </li> <li class="cat-item cat-item-25"><a href="http://wordpressrelated.com/category/wordpress-actions/" title="Wordpress actions">Wordpress actions</a> </li> <li class="cat-item cat-item-24"><a href="http://wordpressrelated.com/category/wordpress-admin/" title="Wordpress admin">Wordpress admin</a> </li> <li class="cat-item cat-item-38"><a href="http://wordpressrelated.com/category/wordpress-ajax/" title="Wordpress Ajax">Wordpress Ajax</a> </li> <li class="cat-item cat-item-40"><a href="http://wordpressrelated.com/category/wordpress-apache/" title="Wordpress Apache">Wordpress Apache</a> </li> <li class="cat-item cat-item-6"><a href="http://wordpressrelated.com/category/wordpress-categories/" title="Wordpress categories">Wordpress categories</a> </li> <li class="cat-item cat-item-22"><a href="http://wordpressrelated.com/category/wordpress-comments/" title="Wordpress comments">Wordpress comments</a> </li> <li class="cat-item cat-item-27"><a href="http://wordpressrelated.com/category/wordpress-css/" title="Wordpress css">Wordpress css</a> </li> <li class="cat-item cat-item-11"><a href="http://wordpressrelated.com/category/wordpress-custom-field/" title="Wordpress custom-field">Wordpress custom-field</a> </li> <li class="cat-item cat-item-2"><a href="http://wordpressrelated.com/category/wordpress-custom-post-types/" title="Wordpress custom-post-types">Wordpress custom-post-types</a> </li> <li class="cat-item cat-item-7"><a href="http://wordpressrelated.com/category/wordpress-custom-taxonomy/" title="Wordpress custom-taxonomy">Wordpress custom-taxonomy</a> </li> <li class="cat-item cat-item-15"><a href="http://wordpressrelated.com/category/wordpress-customization/" title="Wordpress customization">Wordpress customization</a> </li> <li class="cat-item cat-item-21"><a href="http://wordpressrelated.com/category/wordpress-filters/" title="Wordpress filters">Wordpress filters</a> </li> <li class="cat-item cat-item-8"><a href="http://wordpressrelated.com/category/wordpress-functions/" title="Wordpress functions">Wordpress functions</a> </li> <li class="cat-item cat-item-26"><a href="http://wordpressrelated.com/category/wordpress-html/" title="Wordpress html">Wordpress html</a> </li> <li class="cat-item cat-item-16"><a href="http://wordpressrelated.com/category/wordpress-images/" title="Wordpress images">Wordpress images</a> </li> <li class="cat-item cat-item-28"><a href="http://wordpressrelated.com/category/wordpress-javascript/" title="Wordpress javascript">Wordpress javascript</a> </li> <li class="cat-item cat-item-29"><a href="http://wordpressrelated.com/category/wordpress-jquery/" title="Wordpress jquery">Wordpress jquery</a> </li> <li class="cat-item cat-item-14"><a href="http://wordpressrelated.com/category/wordpress-loop/" title="Wordpress loop">Wordpress loop</a> </li> <li class="cat-item cat-item-12"><a href="http://wordpressrelated.com/category/wordpress-menus/" title="Wordpress menus">Wordpress menus</a> </li> <li class="cat-item cat-item-41"><a href="http://wordpressrelated.com/category/wordpress-mod-rewrite/" title="Wordpress mod-rewrite">Wordpress mod-rewrite</a> </li> <li class="cat-item cat-item-13"><a href="http://wordpressrelated.com/category/wordpress-multisite/" title="Wordpress multisite">Wordpress multisite</a> </li> <li class="cat-item cat-item-35"><a href="http://wordpressrelated.com/category/wordpress-mysql/" title="Wordpress Mysql">Wordpress Mysql</a> </li> <li class="cat-item cat-item-19"><a href="http://wordpressrelated.com/category/wordpress-pages/" title="Wordpress pages">Wordpress pages</a> </li> <li class="cat-item cat-item-17"><a href="http://wordpressrelated.com/category/wordpress-permalinks/" title="Wordpress permalinks">Wordpress permalinks</a> </li> <li class="cat-item cat-item-3"><a href="http://wordpressrelated.com/category/wordpress-php/" title="Wordpress PHP">Wordpress PHP</a> </li> <li class="cat-item cat-item-5"><a href="http://wordpressrelated.com/category/wordpress-plugin-development/" title="Wordpress plugin-development">Wordpress plugin-development</a> </li> <li class="cat-item cat-item-1"><a href="http://wordpressrelated.com/category/wordpress-plugins/" title="Wordpress plugins">Wordpress plugins</a> </li> <li class="cat-item cat-item-4"><a href="http://wordpressrelated.com/category/wordpress-posts/" title="Wordpress posts">Wordpress posts</a> </li> <li class="cat-item cat-item-39"><a href="http://wordpressrelated.com/category/wordpress-redirect/" title="Wordpress redirect">Wordpress redirect</a> </li> <li class="cat-item cat-item-23"><a href="http://wordpressrelated.com/category/wordpress-shortcode/" title="Wordpress shortcode">Wordpress shortcode</a> </li> <li class="cat-item cat-item-10"><a href="http://wordpressrelated.com/category/wordpress-theme-development/" title="Wordpress theme-development">Wordpress theme-development</a> </li> <li class="cat-item cat-item-18"><a href="http://wordpressrelated.com/category/wordpress-themes/" title="Wordpress themes">Wordpress themes</a> </li> <li class="cat-item cat-item-20"><a href="http://wordpressrelated.com/category/wordpress-widgets/" title="Wordpress widgets">Wordpress widgets</a> </li> <li class="cat-item cat-item-37"><a href="http://wordpressrelated.com/category/wordpress-woocommerce/" title="Wordpress Woocommerce">Wordpress Woocommerce</a> </li> <li class="cat-item cat-item-9"><a href="http://wordpressrelated.com/category/wordpress-wp-query/" title="Wordpress wp-query">Wordpress wp-query</a> </li> </ul> </div> </div> </div> <div id="footer-wrapper"> <div id="footer"> </div> </div> <div id="bottom-wrapper"> <div id="bottom"> <span class="totop"><a href="#">Back to Top</a></span> 145132 wordpress questions, 32 Wordpress answers.<br /> Wordpress related, All rights reserved <br /> <a href="http://www.creative-advertising.ro" target="_blank" title="Web design, programming, creative advertising">Powered by Creative Advertising</a></span> </div> </div> <script type='text/javascript' src='http://wordpressrelated.com/wp-content/plugins/akismet/_inc/form.js?ver=3.1.5'></script> <script type='text/javascript' src='http://wordpressrelated.com/wp-includes/js/jquery/ui/widget.min.js?ver=1.11.4'></script> <script type='text/javascript' src='http://wordpressrelated.com/wp-includes/js/jquery/ui/core.min.js?ver=1.11.4'></script> <script type='text/javascript' src='http://wordpressrelated.com/wp-includes/js/jquery/ui/mouse.min.js?ver=1.11.4'></script> <script type='text/javascript' src='http://wordpressrelated.com/wp-includes/js/jquery/ui/slider.min.js?ver=1.11.4'></script> <script type='text/javascript' src='http://wordpressrelated.com/wp-includes/js/jquery/ui/button.min.js?ver=1.11.4'></script> <script type='text/javascript' src='http://wordpressrelated.com/wp-includes/js/jquery/ui/spinner.min.js?ver=1.11.4'></script> <script type='text/javascript' src='http://wordpressrelated.com/wp-includes/js/jquery/ui/effect.min.js?ver=1.11.4'></script> <script type='text/javascript' src='http://wordpressrelated.com/wp-includes/js/jquery/ui/effect-shake.min.js?ver=1.11.4'></script> <script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-50118633-1', 'wordpressrelated.com'); ga('send', 'pageview'); </script> </body> </html>