Forums

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

Home Forums Back End Static paragraph before blog posts in WordPress

  • This topic is empty.
Viewing 15 posts - 1 through 15 (of 16 total)
  • Author
    Posts
  • #197094
    gardenshovel
    Participant

    How can I have it so the first paragraph on my blog is static, it always stays there on every page of the blog?

    http://tinyurl.com/obwtzgk

    I’d like to have an introductory paragraph at the top, with a tag list, so ideally it would be editable in WP.

    #197097
    Paulie_D
    Member

    It’s not entirely clear what you are after but it sounds like you need to adjust the page PHP template so that it spits out the same “element” (whatever it is) before the rest of the content.

    Doesn’t sound like a CSS issue so I’ll move it to the WP / PHP issue;

    #197098
    Senff
    Participant

    You’re going to need a custom post type, and then create a new post of that type that contains the text for that static paragraph.

    Then in your single post templates (single.php in a lot of themes, but can be different in other themes), you need to call the contents of that specific static custom post, before the contents of the actual single post.

    #197104
    gardenshovel
    Participant

    Cheers.

    This is the sort of thing I’m after, Paulie:

    http://tinyurl.com/mp2sjg6

    #197111
    gardenshovel
    Participant

    I’m a bit of a novice to this, Senff.

    I think you’re saying duplicate single.php and turn that into a custom post type (think that’s incorrect on my part).

    Then edit single.php so that it calls the custom type. But, wouldn’t that add the static post to every blog post? I only want it at the top of the blogroll pages.

    #197140
    Senff
    Participant

    I think you’re saying duplicate single.php and turn that into a custom post type (think that’s incorrect on my part).

    Indeed that’s incorrect. Working with custom post types is not beginner-level stuff, perhaps not novice-level stuff either so if that spins your brain then maybe that’s not the way to go.

    Editing the single.php file will affect every single instance of every blog post. Try adding something to that file and see what happens. That should give you an idea what working with that template does.

    But, wouldn’t that add the static post to every blog post? I only want it at the top of the blogroll pages.

    Well, before you said:

    How can I have it so the first paragraph on my blog is static, it always stays there on every page of the blog?

    So I’m not sure what you consider the difference between “blogroll pages” and “every page of the blog”.

    #197207
    gardenshovel
    Participant

    Ah, they mean the same thing to me, but what I meant was, I don’t want the extra paragraph to be on the individual posts, only at the top of the “feed” pages.

    E.g.

    Page 1: http://tinyurl.com/obwtzgk
    Page 2: http://tinyurl.com/kbpe7w9

    #197208
    Senff
    Participant

    Then, instead of having it in the single.php template, you should use another template. Depending on the theme, it could be index.php, blog.php, archive.php, or something else. You’ll have to try a few, I guess.

    #197226
    gardenshovel
    Participant

    Update on this (and sort of notes for myself!).

    content.php is the template for the blogroll, I took some source code from a different page (Showreel) and pasted that into content.php above the posts, and it works as I want it, it’s just hard coded into the page so I can’t edit it.

    This is that code: http://codepen.io/anon/pen/wBxeYm

    And this is it in action: http://tinyurl.com/obwtzgk

    Now I’m going to look at the code for page.php and find the part that lines up with the CodePen code, and copy it over to content.php instead, I would assume that would give me an editable region, akin to any other paragraph area on the site.

    Edit: Ah, it hasn’t worked, it’s put it above every post in the blogroll! I hadn’t scrolled down when I wrote the above :S So content.php is the posts.

    #197227
    Alen
    Participant

    @gardenshovel, I see that you’re currently editing…

    I’ve looked at the HTML and you can’t have two same id’s on a same page. Following is incorrect:

    <div id="main" class="site-main">
      <div id="main" class="site-main">
        <div id="primary" class="content-area">...</div>
        <div id="primary" class="content-area">...</div>
      </div>
    </div>
    

    I’m guessing you just copy/pasted stuff around. If you have the original files you’re working with, and you can post them some where, I can take a quick look and tell you how to add static content. In addition, we can make content editable and I can show you how to do that as well.

    #197228
    gardenshovel
    Participant

    index.php is the blogroll page.

    index.php calls content.php.

    content-single.php is a single post’s content when viewed on it’s own individual page.

    I think ideally I’d have my opening paragraph on index.php and content-single.php. That should be easy to copy across once I get the code right!

    I’ve taken a section from full-width.php (the template that every other page on the site uses) and stuck that above the posts in index.php and it’s getting there. It inherits the title of the first post in the blogroll at the moment! http://tinyurl.com/obwtzgk

    This is the section that I’m trying to adapt to work on it’s own, after the header and above the blogroll: http://codepen.io/anon/pen/ZYjJEg

    It requires an article number. The website treats every block of text or post on the site as an article, so I’m not sure how I would create an article to go there that’s “hidden” so to speak.

    #197229
    gardenshovel
    Participant
    #197230
    Alen
    Participant

    So you’ve copy/pasted the code found from line #9 to line #24 in index.php? And this is the place you wish to add static content?

    #197231
    Alen
    Participant

    You’re using this theme https://wordpress.org/themes/minimalizine

    I’ll test it out once I get on my home computer. But just to recap.

    • Static content to show up when viewing blogroll
    • Static content to show up when viewing single blogroll entry
    • Content to be editable via WordPress Admin

    Also, how do you have your Reading Settings set?

    #197232
    gardenshovel
    Participant

    Yes, line #9 to line #24 is correct. And that’s where I want the static content.

    And your bulletpoints are correct also :)

    Also, I’m thinking about having the static content on the tag archives page too, and if possible, have the “Blog” menu option stay highlighted when you go away from /blog.

    So say you click on an individual blog post or choose a tag, the menu option for “Blog” would stay highlighted with the blue rectangle.

    That’s a bit of a slippery slope though perhaps, as then I’d probably want the same thing for the Portfolio sub-pages! Might be a bit too much and unnecessary.

    My reading settings are here: http://tinyurl.com/od3sutn

    Minimalizine is the theme I was using, but I merged it with a child theme to create “Minimal Blue” :P I haven’t replaced the mentions of “minimalizine” within the files though, only the folder name has changed to “minimalblue”.

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