Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Forum: Hacks
    In reply to: Current Page Title or ID
    Thread Starter RUbuntix

    (@rubuntix)

    What do you think about that:

    function extract_page_id($link) {
      preg_match('#page_id=([0-9]+)#', $link, $matches);
      return $matches[1];
    }
    
    $currUri = $_SERVER["REQUEST_URI"];
    echo extract_page_id($currUri)

    ?

    Forum: Hacks
    In reply to: Current Page Title or ID
    Thread Starter RUbuntix

    (@rubuntix)

    I ment “page” in the sense which is implicated
    in the admin-menu. There page seems to be used
    for static pages and for pages, which contain
    posts as well.

    Once again: for static pages I receive the
    correct ID, which I can use for my purpose.
    Only in the case, when there are pages,
    the page-id seems to be hidden by the
    post-ids. But also in this case there
    must be a way to get the title or the ID of the
    page, which contains the posts
    (could it be that I would have to use
    a parent link: is the page the parent of the post?).

    Regarding the custom menu, I would say
    that even if I would use a custom menu
    (my navigation structure is too special for that I guess)
    I still would have to find out the title of the
    currently displayed page.

    Forum: Hacks
    In reply to: Current Page Title or ID
    Thread Starter RUbuntix

    (@rubuntix)

    I try to create a list of pages,
    in which the page, which is currently displayed,
    gets a highlighted color.

    So the one side of what I want is this:

    $pg = get_page_by_title($pgName);
    $id = $pg->ID;

    for getting the IDs for each item in the who list of pages.

    The thing I am missing is just the name of the
    currently displayed page to compare it
    with the above IDs (or names).

    There must be a way to find out, which page
    is currently displayed (or active or shown -> I
    don’t know the correct english wordpress word for this, sorry!).

    Thank you for help!

    Forum: Hacks
    In reply to: Current Page Title or ID
    Thread Starter RUbuntix

    (@rubuntix)

    Yes, it works, but only for those pages,
    which don’t have posts
    (I guess, is_page() is only true in this case).

    So the problem still is, what is

    if (!is_page() {
    ???
    }
    Thread Starter RUbuntix

    (@rubuntix)

    Brilliant!

    Without apply_filters it (as you guessed)
    the content was not parsed for shortcodes,
    but with apply_filtes it did!

    Thank you very much, this was very helpful.

Viewing 5 replies - 1 through 5 (of 5 total)