Tag: PHP

  • Set WordPress Featured Image Automatically

    Anyone who works in his WordPress blog with a picture and always wants or need to put one on his post – depending on the layout implementation, might like this small Plugin, which can do the setting automatically. If not a Featured Image is set it grabs the first image that was uploaded to the…

  • WordPress Options Passed To JavaScript #2

    In our first article of this mini series, I explained how to pass with JSON from PHP to JS. Alternativly you can do this with the WordPress function wp_localize_script(), but contains some pitfalls. Therefore this little tutorial, also you should think about it in advance about these two solutions.

  • WordPress Options Passed To JavaScript #1

    In WordPress you are not always in the PHP world and so you have to pass settings and data from the database to scripts sometimes. In many Plugins you can find solutions in loading the wp-load.php and therefore access to all features of WordPress. Long ago Otto (Samuel Wood) already referred to this fact and…

  • First or Last Page in Page-Structures of WordPress

    Now and then little snippets are pretty useful. For a fix in a Premium-Theme, I needed a kind of evaluation, where I am in the site structure and with little effort I was able to expand the classes and react with CSS. The following code shows the basic for it and get_pages() is the key…

  • Load Minimum of WordPress

    A small contribution for all those using WordPress as a backend, framework or something similar. The applications, especially in the B2B sector, becoming more and more, as do the questions. So far, I’ve always liked to recommended BackPress. But even a well-maintained standard is feasible, with all its advantages in the context of the philosophy…

  • Don’t use strlen()

    Don’t use strlen()

    Each time I see someone use strlen() I cringe. It will break. Despite its name, strlen() doesn’t count characters. It counts bytes. In UTF-8 a character may be up to four bytes long. So what happens if we use strlen() and its companion substr() to shorten the title of post? <?php # -*- coding: utf-8…