WordPress.org

Ready to get started?Download WordPress

Forums

Adding extra page content (13 posts)

  1. Arterus
    Member
    Posted 1 year ago #

    Hi everyone,

    I have attached a screenshot for this problem, hopefully it will help explain what I want to ask.

    I want simply to be able to add some text to the red and green highlighted area in the screenshot. A simple strapline!

    But being fairly new to WP I have no clue how to go about it!

    The 'page.php' displays the page as you see it. (after it calls the header of course) I have called the slider into the page.php, and floated it right (as you can see)

    Below that is the simple 'content' of a normal WP page (as labeled) and a widgetized sidebar with testimonials.

    The problem is, the area I want to put the strapline text in doesn't belong to the 'page' but is part of whats generated by the page.php.

    I 'think' I have to create a new 'div' for the strapline, I get that, and then position it with CSS.
    But where do I write the text? How do I actually go about 'creating' this strapline. I dont know where to 'type' the text for it even!

    This seems like it should be ludicrously easy, but I don't have the first idea...

    Thanks for your help all.

    Art

    <img src="http://i220.photobucket.com/albums/dd65/Kutteruk/help.jpg" border="0" alt="Photobucket"/>

  2. Barry Hughes
    Member
    Posted 1 year ago #

    There are a ton of different places you could store the strapline. How about the tagline field in Settings > General? This would be especially suitable if it is going to be used consistently across the site.

  3. WPyogi
    Volunteer Moderator
    Posted 1 year ago #

    You can add that by editing the header.php file, but it's strongly recommended that you use a Child Theme for any changes to theme file. Otherwise all your changes will be lost when your theme is updated.

    http://codex.wordpress.org/Child_Themes

    If you want it to be easily editable or different on different pages, you could add a widget to the header.

  4. Arterus
    Member
    Posted 1 year ago #

    The theme I'm using wont be updated at anytime, and even if it is, I have butchered it so severely that updating it would indeed be disastrous! :)

    I haven't used a child theme because child css and php files dont overwrite the originals. I did try very hard to make it work, and on emailing the theme makers they told me that the theme wasn't child theme compatible anyway. So....

    As for the suggestion of the tagline, I hadn't thought of that, thanks for the option Barry, but I don't want it to be on every page. In fact I just want it on this page.

    Thanks also for the option of a widget, thats something I did think of, but thought it an unecessary step to simply put what amounts to 10 words on the page.

    So to help me learn, how 'else' could I do this, and where else would the text be sotored, and how would it be called in php?

    Thanks for your time and patience all, its always appreciated.

    Art.

  5. Barry Hughes
    Member
    Posted 1 year ago #

    As for the suggestion of the tagline, I hadn't thought of that, thanks for the option Barry, but I don't want it to be on every page. In fact I just want it on this page.

    You needn't use it on every page (unless you have plans to use the tagline in a different role and it would conflict with that purpose) - you could include it conditionally.

    So to help me learn, how 'else' could I do this, and where else would the text be sotored, and how would it be called in php?

    You could create a page, post or custom post and then pull that in within your template. Again, this could be conditional so that it only turns up on specific pages such as the front page.

    Or you could store it in the options table and then retrieve it again when needed.

    Then again it could simply be a piece of HTML in a template that you fetch in. There a simply a myriad of different ways - personally I'd probably opt for the tagline (site description) or else a custom entry in the options table rather than including another file - but it all depends on what you feel comfortable implementing and how much of a comfort factor you/your client/the person responsible for updating the site is going to need.

  6. Arterus
    Member
    Posted 1 year ago #

    Wow, thanks Barry much appreciated! Much food for thought there, and certainly a lot to get my teeth into.

    My biggest problem (and maybe I could ask you for 1 more piece of advice?) is that the codex reads like its a foreign language to me! Every time I ask about something, or try to google something else I find references to the codex!

    To explain, I am pretty new to this. My wife runs a business whereby she needs a web developer and on loosing 3 of them because they were work shy/useless I decided to step in thinking 'how hard can it be!' lol.. I found out how hard it can be! :P

    I learned CSS and html pretty easily (still learning of course but i'm getting there)

    but learning PHP (specifically wordpress php) is about the hardest thing I have EVER had to do in my life! I have still never coded a single line of php, because when I get to the point I need to, my brain just wont give me the syntax... Then I try and look up what I need.. Get redirected to the codex...

    Rinse repeat.

    I have watched video's, bought 2 books (about php) but getting the 'specific' code I need still eludes me every single time.

    Any suggestions to help me over this monumental learning curve that is PHP?

    Been doing this about 3 months now..

    Thanks for your help, I will try and add this as a template file and include it 'conditionally' in the header so it only shows on my main page.

    php nightmares, here I come (again!) lol :)

    Thanks again for your push in the right direction, I will muddle through this somehow.

    Art.

  7. Arterus
    Member
    Posted 1 year ago #

    Heres a perfect example of how I get 'stuck' to illustrate where I'm coming from.

    <?php get_page($page_id = 306) ?>

    Thats my line of code, I dont know if its right, because when I use it nothing happens.

    If I try <?php echo get_page($page_id = 306) ?>

    I get an error

    Thats it, the extent of my PHP knowledge right there! lol

    It says on the 'get_page' page that this syntax is a way of generating static content for a page. It doesn't really show HOW to do that, it just gives examples (which are none too clear either)

    I believe <?php get_page($page_id = 306) ?> is correct? but I dont know what to DO with that line of code.. It feels to me like theres some kind of 'echo' statement missing to actually print the content of that page to the screen, but I dont know that for sure...

    So I have a page that has my tagline in it.

    I have the php to call the page.

    But nothing happens, so I'm stuck. :(

    Am I being thick? :P

    Thanks for your help all, its very appreciated.

    Art.

  8. Barry Hughes
    Member
    Posted 1 year ago #

    What they're trying to do in the codex is show the function's signature, simply to give you a quick précis of what it is and how it works. When you actually call the function though you just pass in the value (for $page_id that would be 306, in your example):

    $page = get_page(306);

    If 306 is a valid page ID you will then be in possession of an object called $page and you can then do what you like with it - for instance you could print out the page title:

    echo $page->post_title;

    Or the page content:

    echo $page->post_content;

    So far so good? Although it's going off-topic a little I'd also suggest reading up on filters (and the default filters that WordPress normally passes posts through) - it may not matter tremendously if you are using this technique to store and print out a slogan, but if you apply it in other circumstances it almost certainly become relevant at that point :-)

  9. Arterus
    Member
    Posted 1 year ago #

    You are a star Barry, that actually does make sense! I have to go out this afternoon, and probably wont get round to this until late evening or maybe next Monday now but I can't thank you enough for your help.

    I will work on the premise that I now have a variable that I can manipulate as soon as I get the chance.. Thx again. Speak soon!

    Art.

  10. Arterus
    Member
    Posted 1 year ago #

    Oh man! I thought I understood what this meant... i was fairly confident I could make this work, yet this morning after 2 hours of trying I cant get a single thing to work.

    As I understand... with the line of code I have

    <?php get_page($page_id = 306)?> I am 'assigning' 306 (the actual id number of the page I want to put on screen) to a variable called $page_id??

    Thats probably wrong, but like I say, I'm a noob :P

    Ok, so then when I have a variable I can play with filled with info about page 306 (stored as an array??? - again not sure here just testing the water) I can ask WordPress to 'print' onscreen the info in the variable.

    <?php echo $page -> post_content; ?>

    When I put these in my header, nothing happens.

    I also don't really know how to make this 'conditional', even if it did work! I really am struggling. :(

    I don't know if you can help me here Barry, (or anyone) I just don't seem to be able to 'grasp' PHP at all and seriously don't know what to do next.

    Thanks as always for your help,

    Art.

  11. Barry Hughes
    Member
    Posted 1 year ago #

    This won't work as you expect (also, I've misled you a little - get_page() will work but should be avoided):

    <?php get_page($page_id = 306)?>

    Instead, do this (note we've switched to using get_post()):

    <?php $page = get_post(306); ?>

    Also, don't add extra spaces in there or PHP will not understand you! This will not work:

    <?php echo $page -> post_content; ?>

    This will:

    <?php echo $page->post_content; ?>

    Putting it all together, something like this ought to work for you.

    If not then it might be worth considering a different route, like adding the "strapline text" as plain old HTML in the relevant template. It could be worth running through a few basic PHP tutorials first of all though and then taking another look at this stuff :-)

  12. Arterus
    Member
    Posted 1 year ago #

    Your help is always appreciated Barry, thanks again. I will try this later on tonight.

    As for tutorials, I've done LOADS of them. Lynda.com, Killersites, Theme forests developers series (15 days)

    The problem is I have ZERO experience with it, and I'm sure you appreciate until you get hands on you will never learn this stuff.

    The other problem I find is 'specifics'. What I mean here is that no matter how many tutorials I watch/participate in I still wont know how to use get_page or indeed get_post as described here.

    I have a lot of knowledge about php, a lot has gone in.. but when it comes to doing it myself I just cant recall the relevant parts.

    I am very frustrated with it all now, as my wife needs these done before xmas and its simply not going to happen.. Oh well, I did my best.

    Your efforts are extraordinary though Barry, thanks again.

    Art.

  13. Barry Hughes
    Member
    Posted 1 year ago #

    No problem at all, it's always tricky at the start. We can keep chipping away though - why don't you share what you've done so far using a service like Pastebin or Gist?

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags

No tags yet.