The forums ran from 2008-2020 and are now closed and viewable here as an archive.

Home Forums Back End Dynamically link to child page WP

  • This topic is empty.
Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • #30817

    I’m using subpages on a WP site as follows;

    Products (Parent Page)
    -Office (Subpage 1)
    –Office Gallery (Child of Subpage 1)
    -School (Subpage 2)
    –School Gallery (Child of Subpage 2)

    How can I create a link on each subpage to its child page using just one template in my theme? I need to be able to give this link a css class name. In other words I need to have the code in my page template look something like


    or something like that……

    I tried using wp_list_pages for a child page from the WordPress Codex but this returns a list and I really need just the permalink to the child page.

    Is this easy? Impossible?

    Thanks in advance.


    You can do it by giving your pages tag id’s.

    Then use jquery or javascript to determine whether a page is a subpage and if it is then those links will link to it’s parent..

    My jquery/javascript isn’t very strong but it would be something along these lines:

    if($("body").attr("id", "products_sub")) {
    a.class_name.attr("src", "products.php");

    I might be wrong but you can try playing around with that.

Viewing 2 posts - 1 through 2 (of 2 total)
  • The forum ‘Back End’ is closed to new topics and replies.