WordPress.org

Ready to get started?Download WordPress

Forums

loop_start elements added to RSS feed? (16 posts)

  1. harknell
    Member
    Posted 7 years ago #

    If a plugin adds some content at the loop_start point of the WordPress page load it appears that this content is being added to the RSS feed output. Is this the proper action? If so it is not stated anywhere that this would be the result of placing something at this point.

    I have some plugins that use the loop_start tag to display information to the visitor above the posts area, but this info is being added to the RSS feed listing as HTML fields. Most RSS readers will ignore this text (since it does not correspond to the proper XML fields), but it's certainly annoying and not something I'd like to have happen. Is there a way to prevent this?

    You can see this in action by going to my development website http://www.awsom.org and clicking my RSS feed link, you'll then see from the page source view that my drop down archive is added to the RSS stream.

    Is there some kind of filter I could use to prevent this from being output?

  2. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Yes, even the RSS feed has a Loop. So yes, it will call loop_start. If you don't want that, don't use loop_start.

    Or, have your function check if you're in a feed.. You can do that like this:

    if (!is_feed()) {
    // not in a feed, go nuts
    }
  3. harknell
    Member
    Posted 7 years ago #

    The weird thing is there are no other calls available that occur after the header is done, but before output is done for the main index page. loop_start is it, and if the output is being put into the rss loop, that's a problem. Especially since there are specific calls to the rss feed content that are available. I would hope that there would be an rss_start call that would be separate, and that loop_start would literally be before any loop actions such that the content added at that point would not be a part of the actual loop itself. Or better yet, create a new hook called content_start or something that takes place before any of the_content actually happens.

  4. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    The weird thing is there are no other calls available that occur after the header is done, but before output is done for the main index page. loop_start is it...

    No, loop_start is an action hook that happens at the start of the Loop (during the first call to the_post()). What's more, it can happen multiple times, since some themes have multiple Loops. So you should not rely on it to be "after the header", because that is not its purpose. Its purpose is just what it sounds like, to be at the start of the Loop. Just like loop_end is at the end of the Loop.

    ...and if the output is being put into the rss loop, that's a problem

    Again, no, not really. The feed contains a loop too. If you are just wanting to put output into the page before the loop, then you should not be doing it on a loop_start action hook. Instead you should create a function call and then add that function call to your theme in the proper location. If you're writing a plugin, then tell the user to add your function call to the right location in their theme. Every theme is different, not all things can be automatically added to the page output.

  5. harknell
    Member
    Posted 7 years ago #

    I understand your position, but the current situation for WordPress in this area is very lacking. It mystifies me that out of all of the possible action hooks possible there isn't one for the specific area between the header and the main content of the page. I'm sure I'm not unique in wanting this type of hook, nor am I the only one who uses loop_start since there aren't any other options.

    While it is true that the user could go and change their theme files, that defeats the whole concept of using hooks to allow plugin to add things to the page. It is additionally true that many users are not confident enough to do some types of editing to their files--my purpose is to make things such that they don't need to fumble with file editing, since many of my users don't even know HTML, much less be able to understand a php file.

    Anyway, I'll try using !is_feed() and also see about eliminating multiple displays if a loop is cycling.

  6. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    While it is true that the user could go and change their theme files, that defeats the whole concept of using hooks to allow plugin to add things to the page.

    That's not the point of action hooks at all. Plugins can indeed add things to the page that way, but the goal of action hooks is to let plugins execute certain actions at the right times, not to just provide handy output points.

    Themes are end-user editable. Always have been. If you want to change the look of a page, or insert something, then you modify the theme. That's the purpose of the theme.

    It is additionally true that many users are not confident enough to do some types of editing to their files--my purpose is to make things such that they don't need to fumble with file editing, since many of my users don't even know HTML, much less be able to understand a php file.

    While I understand what you're saying, the problem with adding "display hooks" to theme's is simply that not all themes will have them. Even simple functions that call hooks, like the wp_head action hook, are frequently left out of themes. Okay, not out of *good* themes, but if we start requiring action hooks or even certain types of function calls in themes, then it's virtually certain that some theme's are not going to have them. And what then? The user has to edit the theme to add the hook or function call.

    It's simpler to simply not have action hooks like this in themes. And you'll note that the only action hooks we use in the default themes is the "comment_form" hook. We also have wp_head, which is also little more than an action hook, just wrapped in a function...

  7. harknell
    Member
    Posted 7 years ago #

    Honestly, My take on things is that the ultimate goal of a system like WordPress is to eliminate anything that requires editing of files by the end user to affect output. Content and output style should be separate, and nothing should ever be hard-coded. If it were possible I would love it if the entire page could be replaced and called by hooks and actions, such that there wasn't anything that couldn't be altered through plugins.

    My suggestion would be that the default theme would have the ability to be infinitely altered by supporting any output hook or action--so a non-technical user could go to a plugin database and assemble their page by simply adding the plugins that made the page look the way they wanted, like a puzzle. Sort of like how the makers of the Canvas plugin want to add the ability for a drag and drop layout of the page. In the ultimate take on this there really wouldn't be a theme file at all, just components/plugins that could be turned on or off to display different areas that then combined to form the whole page.

  8. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    Well, we disagree on the ultimate goal then, because I would certainly not use such a system. It would not be flexible enough for, well, anything I'd use it for.

    The theme system is infinitely better, IMO. Much better to have capabilities which you can plug together in different ways than to have a fixed rigid structure which cannot be easily altered by the end-user.

    I suggest that you try Joomla or Drupal instead of WordPress.

  9. harknell
    Member
    Posted 7 years ago #

    Um, I'm not sure if you understood my suggestion, since my suggestion actually sounds more like a flexible system that allows for plugging in different elements than the current theme system. The theme system now is actually half based on hard coding, which actually inhibits true flexibility. If every part of the "theme" were pluggable then anything could be placed anywhere, which is the most flexible thing possible.

  10. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    On the contrary, your system sounds far more rigid. You're defining everything in terms of blocks which you move around and place on the page. However, that design technique can only go so far. What if I don't want block design? What if my design is more free-flowing than your block system is capable of describing?

    Block design is too limited for anything more than common tasks. This is why Canvas failed, it's too limiting and technically difficult to boot.

    The theme system, on the other hand, is infinitely flexible. It doesn't matter what design pattern I want to use, I can use any design I like. WordPress provides me with a set of tools I can use in various ways, and it provides me with various types of things as well. These include things like categorized time-based textual content (posts), non-time based textual content (pages), categorized URLs with metadata (bookmarks/blogroll), user-definable and configurable list based content (widgets), and so forth. I can put these together any way I choose by simply defining the page itself in the theme. You cannot get much more flexible than the theme concept.

    I understand what you're saying: You don't think user want to edit text or edit themes. And that's as well as may be, however, I firmly disagree with that notion. Both with the idea of what the users want, and with the idea of making WordPress less technically capable simply to accommodate the less technical users. There are limits to how much you can "dumb it down" before you lose the entire point of having the thing in the first place.

  11. moshu
    Member
    Posted 7 years ago #

    There are limits to how much you can "dumb it down" before you lose the entire point of having the thing in the first place.

    I love this. It should be posted everywhere in this instant-gratification-user-friendly craziness world...

  12. whooami
    Member
    Posted 7 years ago #

    OMG! How I SO agree!!

  13. harknell
    Member
    Posted 7 years ago #

    Guys, what I'm suggesting is not to remove things but to extend them. Let's be real, 99% of WordPress installs are all comprised of the same elements of header, sidebar, content, footer, so the "block" design is already there. What I would like to see is more granularity in how each section can be called, so that more elments of the theme can actually be added or altered by plugins. Those of us who actually know how to code will always be able to add the elements we want anyway regardless.

    Keep in mind, we've all chosen to devote our time to learning code and such, most people don't have the time or ability to do this--this is not a case of dumb, just of different capabilities or priorities.

    Most of the people who I work with are Artists, they spend their time working on content. That's their thing. Are we dumb because some of us don't know how to draw perspective? Depends on who you ask....

    Anyway, I certainly don't want to remove the theme system, just have an alternate and complimentary capability to access those areas of the page that are normally there anyway-- there isn't really a reason why those hooks can't exist, they just don't at the moment.

  14. harknell
    Member
    Posted 7 years ago #

    Oh, btw, I think I fixed the original issue, so thank you for the info.....

  15. Samuel Wood (Otto)
    Tech Ninja
    Posted 7 years ago #

    there isn't really a reason why those hooks can't exist, they just don't at the moment.

    Actually, the reason those hooks don't exist is because the hooks you're describing would have to be in the themes themselves. And thus you would not be able to count on them always being there.

    It's amazing how many themes don't call wp_head(), for example.

  16. harknell
    Member
    Posted 7 years ago #

    I understand that many themes wouldn't have them, but if a bundled theme with wordpress did have them (sort of like the 2 currently) then at least one default one would be able to do the stuff. Plus, if they were there they'd be supported by some people.

Topic Closed

This topic has been closed to new replies.

About this Topic