Archived topic
Instal date/time
36 replies · Started by JOAQUIM GALANTE on May 15, 2020
I am use the pluginception and when i activate the code below said 'Fatal Error'
add_shortcode( 'custom_date', function() {
$time_string = '<time class="entry-date published" datetime="%1$s" itemprop="datePublished">%2$s</time>';
if ( get_the_time( 'U' ) !== get_the_modified_time( 'U' ) ) {
$time_string .= '<time class="updated" datetime="%3$s" itemprop="dateModified" style="display:none;">%4$s</time>';
}
$time_string = sprintf( $time_string,
esc_attr( get_the_date( 'c' ) ),
esc_html( get_the_date() ),
esc_attr( get_the_modified_date( 'c' ) ),
esc_html( get_the_modified_date() )
);
$date = sprintf( '%3$s',
esc_url( get_permalink() ),
esc_attr( get_the_time() ),
$time_string
);
return $date;
} );
How can i solve the problem ?
Hi there,
Can you try the Code Snippets plugin as David suggested several times here?
https://generatepress.com/forums/topic/some-improvements-if-possible/#post-1285477
I just tested the code and it works.
Yes, David told me that but once i installed this program and i puted the code when activated i need to recover the site because a fatal error appear, since then always i install the Code Snippets plugin and activate it a fatal error occurs.
I use Pluginception and in this plugin the code give a 'Fatal error' when active.
Pluginception is not what you want to use.
Can you disable that for now?
Have you added anything else within CodeSnippets?
The plugin by itself cannot cause a fatal error. We use it ourselves and lots of users are using it as well.
With Pluginception i have 2 plugins about the features grid and function very well.
I am affraid to install code snippets because when i go activated the plugin imediately occur a 'Fatal Error'
One time i add a code send by Tom in codesnippets i made some changes in code (because the code didn´t function) and did a 'Fatal Error' i resolve the problem and desactivate and uninstall de plugin.
One hour later more or less i resolve to install again (codesnippets) and when activate the plugin imediatly wp advise 'Fatal Error'.
Then try function.php of a child theme:
Adding PHP: https://docs.generatepress.com/article/adding-php/
I'm not sure what you are using Pluginception for but it sounds overkill for what you need.
Code Snippets or function.php would be the better choice.
I use pluginception because snippets give a fatal error and in that link https://docs.generatepress.com/article/adding-php/ pluginception is the second option.
Take a look at the
How can I recover my site if it is crashed by a buggy snippet?
or
Can the plugin be completely uninstalled
Ok, tell me have a trouble if the pluginception and codesnippets are both active ?
It shouldn't be. But it's best to fix the Code Snippets using one of the methods I mentioned above.
Thanks, when the Fatal error occurs the wp automatcaly put in the safe mode and i delete the plugin.
Now, I already install the snippets but i am affraid to activate it my aknowledge is poor and if i have a seriously problem i don´t know how to solve the problem and i lost the site. :)
Thanks a lot.
So is the Code Snippets plugin activated now?
If so you just want to make sure the copy and paste this code exactly then you should be fine:
https://generatepress.com/forums/topic/shortcode-for-current-date/#post-632065
Please don't modify the code.
When activate the Code Snippets look what happend.
An easy, clean and simple way to run code snippets on your site. No need to edit to your theme's functions.php file again!
Versão 2.14.0 | Por Code Snippets Pro | Detailes
This plugin failed on charge and it is suspended during the recuperation mode.
An error type E_COMPILE_ERROR caused in line 7 of file /home/oe3pog5g/public_html/wp-content/plugins/code-snippets/php/snippet-ops.php(446) : eval()'d code. Error Message: Cannot redeclare my_function_for_excluding_posts() (previously declared in /home/oe3pog5g/public_html/wp-content/plugins/magazinegridfrontpage/magazinegridfrontpage.php:12)
Can you disable plugin magazinegridfrontpage?
Or remove all existing snippets in Code Snippets?