like to keep reading plugin

I am using the like to keep reading plugin.

I have created some code in index.html file.

Read More

I use this code

[like_to_read] some code here [/like_to_read]

That is not working.
But if I use in this in a post it will work like a charm.
I, however, want to use in index.html.

How can I achieve that?

Related posts

2 comments

  1. There are three major flaws with what you’re asking:

    1. You are attempting to use a WordPress API in a file loaded separately from WordPress. This will only work if you include WP in that file (resulting in the performance difference you likely expected to gain by loading a static file vs. a page/post being pretty much diminished).

    2. This API itself is written in PHP. The function(s) necessary to interpret shortcodes are PHP. You want to put shortcodes in an .html file. Again, bound to fail.

    3. Shortcodes are interpreted by default if in post content, but if you want them to get interpreted by the API outside of post content, you have to make use of do_shortcode.

    Hence, though, from what I can see, it’s probably a bad architectural idea in the first place, theoretically, a mock-up of a separately loaded php file that does support shortcodes could look like so:

    <?php
        define('SHORTINIT', true); /* load WP minimally, optional */
        require '/path/to/wp-load.php';
    
        echo do_shortcode( "[like_to_read] some code here [/like_to_read]" );
    ?>
    
  2. 1) Put this in your Apache configuration file (httpd.conf), so html files will be interpreted as php files:

    AddType application/x-httpd-php .html
    

    2) And try something like this inside your index.html:

    <?php echo do_shortcode("[like_to_read] some code here [/like_to_read]"); ?>
    

    But, I think that it’s a very bad practice to use html files to run php. For example, if the PHP interpreter failed for some reason the php code will be displayed in the browser because it’s and html file. Thi sitaution can happend if you for example change the hosting porvider and you forget set the Apache to parse html as php. And also there is a speed issue, because HTML files parsed as PHP will technically load slower, because you’re invoking the PHP engine.

    So, if you have only a few files saved as .html change them to .php and it will be OK. It doesn’t mean that if it’s called something.php it has to contain php code. not at all. But it can if you want 😉

Comments are closed.