Support » Fixing WordPress » adding “#” to my link

Viewing 4 replies - 1 through 4 (of 4 total)
  • Joy

    (@joyously)

    What is the context? (creating a menu, code for plugin)
    Why would you want to do that? And is it only in one place?

    fritzdultimate

    (@fritzdultimate)

    I’m trying to customize my pages that have children, I’m creating a theme, so I want to create an option on the admin customize panel where the user of my theme can choose if they will want the content of the children pages to appear on the parent page or not.

    Now the deal is, if the content are to appear on the parent page(Showing the content of the children page to the parent page)

    The children links which will be seen on the parent page will be an anchor links e.g sub page

    So that when a user clicks on it will push the page down to the unique paragraph.
    I will be creating the paragraph within the page slug name as the id.

    full example.

    In About page we have the sub page(children) > vision, mission, developers.

    
    <a href="site-url/about#vision">vision</a>
    <a href="site-url/about#mission">mission</a>
    <a href="site-url/about#developer">developers</a>
    

    Then the mark up on the parent page will be:

    
    <div class="content">
    <nav>
    <a href="site-url/about#vision">vision</a>
    <a href="site-url/about#mission">mission</a>
    <a href="site-url/about#developer">developers</a>
    </nav>
    
    <p id="vision"> the content </p>
    <p id="mission"> the content </p>
    <p id="developer"> the content </p>
    </div>
    

    I will prefer if the solution would be creating a function that would be called when desired.

    Hope it’s clearer now?

    Joy

    (@joyously)

    I hope you realize that this is out of scope for a theme, which should just be displaying whatever the query is for. It also affects SEO, and would trigger a duplicate content penalty since the subpage is still available for viewing at another URL.
    It also does not make sense to use a <p> tag around unknown content, which likely contains <p> tags (they should not be nested).

    You do not need the entire link. Just use #page-slug since it’s within the same page. But be aware that a slug can start with a number and it’s best if IDs start with a letter. You can choose a prefix, so they all conform.

    fritzdultimate

    (@fritzdultimate)

    Ok thanks, I understand the point you’re making.
    So now I’m thinking of using the page slugname to achieve my aim.

    The idea that the page content comes with a <p> tag isn’t my problem, because I have had that problem curbed.

    Since you said this can have SEO issue, I think I should back off.

Viewing 4 replies - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.