• I have a requirement where if a user enters http://www.abc.com/#3121 page, i want to show him/her all posts BUT with post number 3121 on the top and preferably in a highlighted div.

    Any suggestions on how can i achieve this. Also at present page is using query_posts codex to get the posts from the db.

Viewing 1 replies (of 1 total)
  • Hello,

    The hash of a URL (#3121 in your example) is not passed to the server, so is unavailable to PHP. You can access this via JS, though (window.location.hash) and could manipulate the DOM to move the article to the top, or trigger an AJAX request to redraw the page.

    Alternatively, if you’re amenable to using a GET parameter instead of a hash, you could check for the existence and value of said parameter and modify the query – either in one of the theme template files or in a pre_get_posts hook.

    Thanks,
    Lucas

Viewing 1 replies (of 1 total)
  • The topic ‘Display selected post on top (based on parameter)’ is closed to new replies.