• Dear all, I have added to my child-theme some lines in archive.php template, which point to some category IDs, all works fine.

    But among this html there is also some h1 text which should be updated frequently, and I want to manage it from external path.

    To do this, may I use the php function “file_get_contents()” (+ url) pointing to an external .txt file?

    Or as alternative something like “$xxx_string = include('text.txt');” (+ url), pointing to an external .txt (which in this case should start with “<?php return“)?

    Or which is the official wp method to achieve this?

    Thank you in advance.

Viewing 4 replies - 16 through 19 (of 19 total)
  • Moderator bcworkz

    (@bcworkz)

    such input solutions are very hard to apply

    !?? That’s debatable ?? There are many custom fields plugins that make this relatively easy IMO. “ACF” being the most poplar.

    The other side of the coin is outputting the data acquired by custom fields in the format you want. Usually the shortcodes provided by the plugin are adequate, but in some more challenging cases a custom template might be warranted, then requiring some modest PHP coding skill.

    If someone had such coding skill, it’s feasible to build both the input and output portions on a single custom template, no plugin necessary. Probably not much more difficult than coding something that reads and parses an external .txt file in order to update a post or page ??

    Thread Starter Mauro Vicariotto

    (@mrosfy)

    Dear @bcworkz,

    I really never understood why some wp developers discouraged me from going down the road of external interfaces to wp: I just had strict time and given their reaction (in that case we never even went into the matter, only generically mentioned .xsl or .csv interfaces) I just put that project in stand-by.

    Yes, I can write some good codes in php (of course takes time because I’m surely not “top level” indeed), but in any case I prefer to avoid plugins for some special issues, because generally the plugins have fixed design, and you lose more time to tewak a plugin than to make it.

    Thank you for your good suggestion (I really never understood why I was discouraged that time, a couple of years ago, probably the developer didn’t have skills in php, or simply didn’t want to enter too much in the matter: practically the reply was that “wp is a fixed machine, and to do what I wanted I should have entered in deep system, modding parts out of wp-content … bah)

    Moderator bcworkz

    (@bcworkz)

    I think some “developers” who “build” sites really only create content and don’t really code beyond HTML and CSS. Anything involving actually needing to script or program something scares them due to their lack of knowledge. Their view of what’s possible is thus very skewed. Perhaps they don’t have the luxury of time to push their skills to the next level because they need to generate income to feed their family. I’m trying to give these purveyors of misinformation the benefit of doubt ??

    I prefer to avoid plugins for some special issues

    I generally lean that way myself, but if a plugin does something complex quite well with little or no modification at no or reasonable cost, I’m quite happy to use it. While I may have the time and ability to “reinvent the wheel”, I still value my time and don’t wish to squander it. Or if I choose to, that’s not where I’d spend it. Coding is only tertiary to my profession, it’s mostly a hobby for me.

    The plugins I do use tend to be more like developer tools more than turn key solutions. They make it easier for me to reach my goals without spending time coding functionality that I’m not particularly interested in developing. ACF for example. I’m capable of adding my own custom fields in meta boxes, but ACF can do this for me. Then I have more time to develop something that makes use of the custom field data.

    Whichever approach you chose to use, I hope you find implementing it enjoyable.

    Thread Starter Mauro Vicariotto

    (@mrosfy)

    @bcworkz, totally agree with you about developers.

    Regarding plugins of course I use some of them too when useful, but most of sites I make are highly personalized and too often I lose a lot of time to adapt the plugin to my needs, anyhow I also confirm that some tech plugin is absolutely useful.

    (I’m not a professional programmer either but as a hobby, or to create websites and IT parts for my activities)

    Thank you for all, it was a very pleasant discussion, and I really hope that we will keep in touch

Viewing 4 replies - 16 through 19 (of 19 total)
  • The topic ‘file_get_contents() in wp template’ is closed to new replies.