WordPress.org

Ready to get started?Download WordPress

Forums

Add custom code to wordpress page (9 posts)

  1. HeyBlondie
    Member
    Posted 2 years ago #

    I have recently installed wordpress on my server and added a blog page to my site.

    I want the blog page to look like the rest of my site (which is written by myself in html/css/php) and want to know how I can add additional code and formatting to a wordpress site/page? (something *not* controlled by wordpress or it's theme)

    Basically, all I want to do is add the top menu from the other pages of my site, to the very top of the WordPress page (ie, above the wordpress header). This menu isn't to be the WordPress menu, but merely navigation for my own site. I will retain the wordpress menu underneath the header which is just for use on the blog side of things.

    I have already altered the formatting of the wordpress page using a Child-Theme of Twenty Eleven and that works fine. I'm not sure how to add my own menu at the top though.

    I have edited the wordpress 'index.php' file (by adding my own code to the beginning of it) but I'm sure this is not the right way to do things.

    This link shows how I would like it to look louisebagger.com/blog ...the menu at the top is my own, and everything below it is the standard WordPress blog.

    I am finding it difficult to explain what I need to do because I don't think I know the right terms to use? Hopefully someone can offer some insights?

    Thanks

  2. Altaf Hussain Patel
    Member
    Posted 2 years ago #

    so you have to modify header.php and index.php
    check index.php and copy the code of the pages is_pages() i think see the documentation and remove the code means cut it and paste in header.php

    Note: Backup the files first when you are playing with coding.

  3. HeyBlondie
    Member
    Posted 2 years ago #

    I have found one way of achieving what I want, but it wasn't ideal.

    I have copied the themes 'header.php' file to the bchild directory and added code in there. The main problem is that the code is kept within the mean 'div container' for the page, so I've had to add my own 'div' with a negative top margin to have it appear above the WordPress header.

    Seems a bit crude, but it works.

    My menu is linked to a stylesheet and I linked it like this (up with other stylesheet links at the top of the header.php file):
    <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_directory_uri(); ?>/name_of_stylesheet.css" />

    Hopefully this might be of help to others?

  4. HeyBlondie
    Member
    Posted 2 years ago #

    Thanks Altaf ...I just saw your post after adding my own reply...

    If you might know of a better way to achieve what I've done, please let me know. You can have a look at how things are done with the firebug add-on for firefox/chrome

  5. kmessinger
    Volunteer Moderator
    Posted 2 years ago #

  6. HeyBlondie
    Member
    Posted 2 years ago #

    It probably is. ...I had tried in various places and I found I had to pose different questions to finally arrive at the answer I needed.

    It's difficult to get the answer you need when you don't know the right questions to ask. It's all a learning process.

    I knew there had to be a simple solution and in the end I was able to ask my question to get that simple solution.

  7. HeyBlondie
    Member
    Posted 2 years ago #

    ....mind you, I still haven't actually been provided with exactly the help and information I wanted, but at least it's working and doing what I want it to do.

  8. esmi
    Forum Moderator
    Posted 2 years ago #

    The other post has now been closed.

    @HeyBlondie: Please do not post the same question multiple times. All you end up doing is wasting the valuable time of forum volunteers.

  9. HeyBlondie
    Member
    Posted 2 years ago #

    My apologies.

    In my view it was a differently worded question and would only have confused the issue on the previous post. After numerous tries I wasn't getting the answers I needed and felt it best to address it differently in a new post.

    No intention to offend.

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.