Forum Replies Created

Viewing 15 replies - 1 through 15 (of 24 total)
  • Plugin Author Atif Riaz

    (@lightbulbman)

    Hi @shannonsadik

    Thanks for the reply and update,

    Can I check the code you shared – are you adding exactly this code into a HTML snippet and inserting via a shortcode or in the head/ body section? If you can provide some further explanation of how you have this working / set up I think it will help clarify where the problem may be and the resolution.

    I notice the pages linked look fine when I view them so perhaps this may already be resolved, hence why I will set this topic to resolved but your more then welcome to reopen if its still ongoing and we are happy to help.

    Wishing you all the best.

    Plugin Author Atif Riaz

    (@lightbulbman)

    Thanks for your follow-up!

    Regarding your question, HTML snippets allow you to add raw HTML directly to your site. However, for cleaner organisation, better management, performance and correct optimisations, you should use the dedicated CSS or JavaScript snippets for styling and scripts.

    As for code placement:

    • PHP snippets (global mode): Injected typically before the closing </body> tag.
    • HTML snippets: Placed in the body section, often in the header.
    • CSS snippets: Injected into the <head> dynamically.
    • JavaScript snippets: Injected into the <head> or just before </body>, depending on your settings.

    Code Snippets simplifies adding code without needing manual enqueues or theme file modifications.

    Hope this helps.

    Plugin Author Atif Riaz

    (@lightbulbman)

    Hello @brandsline

    Thanks for reaching out and apologies for the issue your facing,

    I’ve tested a PHP snippet using foreach and wasn’t able to reproduce the issue nor am I aware of any other reports of this issue or similar. Could you please check that you’re using the latest version of both WordPress and the Code Snippets plugin?

    If the issue persists, please share the full code you’re using with our support team via email. This will help us investigate further.

    All the best.

    Plugin Author Atif Riaz

    (@lightbulbman)

    Hi @qwertius

    Thank you for raising this issue and apologies that you are facing a problem.

    I can update you that it has been added to our dev board as a potential bug that needs investigation and fix, and we will be investigating it. We’ll work on resolving it in due course, and always do prioritise bug fixes alongside new features and will hope to get this resolved by the next update. Please bear with us and we appreciate your patience.

    You can keep track of this and updates from the issue created on Github:

    https://github.com/codesnippetspro/code-snippets/issues/228

    Many thanks for your help

    Plugin Author Atif Riaz

    (@lightbulbman)

    Hi @lyk-1

    Thank you for raising this issue and apologies that you are facing a problem.

    I can update you that it has been added to our dev board as a potential bug that needs investigation and fix, and we will be investigating it. We’ll work on resolving it in due course, and always do prioritise bug fixes alongside new features and will hope to get this resolved by the next update. Please bear with us and we appreciate your patience.

    You can keep track of this and updates from the issue created on Github:

    https://github.com/codesnippetspro/code-snippets/issues/227

    Many thanks for your help

    Plugin Author Atif Riaz

    (@lightbulbman)

    Hi @ghsu292

    Thanks for reaching out. The error message “Attempt to read property ‘ID’ on null” suggests that the code is trying to access an object’s ID property, but the object itself is null (i.e., it doesn’t exist at that moment).

    Before accessing the ID property, you should check whether the object exists. For example if your snippet is trying to get the ID from a post like the following you could do something like this:

    if ( get_queried_object() ) {
    $post_id = get_the_ID();
    } else {
    $post_id = 0; // Or handle it appropriately
    }

    To help further, more details on what is attempted to being accessed would be helpful. In any case the above explanation will apply.

    Hope this helps.

    Plugin Author Atif Riaz

    (@lightbulbman)

    Hello @pletershek

    Thanks for reaching out and sorry your facing problems. It looks like the error is caused by a type mismatch—specifically, a float (decimal number) and a string being added together. This may have started happening after your PHP update because newer versions of PHP are stricter about type handling.

    To fix this, you’ll want to ensure that both values being added are numbers. Try updating your snippet like this:

    $variable1 = floatval($variable1); // Ensure it's a number
    $variable2 = floatval($variable2); // Ensure it's a number

    $result = $variable1 + $variable2; // Now both are floats, preventing the error

    If you’re unsure which variables are causing the issue, you can try debugging using WordPress debugging or a plugin like variable inspector.

    To use WordPress debugging this needs to be enabled, by setting (WP_DEBUG in wp-config.php) to true.

    error_log( 'Variable 1: ' . gettype($variable1) . ' - ' . print_r($variable1, true) );
    error_log( 'Variable 2: ' . gettype($variable2) . ' - ' . print_r($variable2, true) )

    Then check your error log (wp-content/debug.log) to see their types and values.

    Hope this helps

    Plugin Author Atif Riaz

    (@lightbulbman)

    Hello @pavman

    Thanks for sharing these details and really sorry your facing these issues.

    It sounds like the database structure may not have been updated correctly after the recent update, which could be causing the issue where snippet changes appear to save but don’t persist.

    A couple of things you could try:

    1. Manually trigger a database update using debug: Some updates require running a migration script. You can try manually updating the database by going to settings then the debug submenu and clicking on the ‘Upgrade Database Table’ button.
    2. Manually trigger a database update using deactivate/activate: Try deactivating and reactivating the plugin to see if it applies any necessary database changes.

    If either of the above don’t work then if you can enable wordPress debugging (WP_DEBUG in wp-config.php), and check the logs for any database or related errors – wp-content/debug.log. If you can share any errors in the logs directly by contacting our support via email we can investigate further.

      Hope this helps.

      Plugin Author Atif Riaz

      (@lightbulbman)

      Hello @hkcecselinay

      Thanks for reporting the issue and apologies you are having this problem. I am really sorry but I am not able to reproduce this error or aware of reports of similar. However, the error you shared suggests there might be a conflict with another plugin, a caching issue, or a problem with how the JavaScript files are loading.

      Could you please try the following troubleshooting steps?

      1. Clear cache: If you’re using a caching plugin (e.g., LiteSpeed, WP Rocket), try clearing the cache and refreshing the page.
      2. Disable other plugins: Temporarily disable other plugins to check if there’s a conflict.
      3. Try in a different browser or incognito mode: This helps rule out browser-specific caching issues.
      4. Reinstall the plugin: Try deleting and reinstalling Code Snippets to ensure all files are correctly updated.

      If the issue persists, let us know any additional details, such as your WordPress version and active plugins. We’ll do our best to help! ??

      All the best

      Plugin Author Atif Riaz

      (@lightbulbman)

      Hi @gudrunpetz

      Thanks for your question and I hope I have understood correctly, does your snippet add[advertisement] dynamically using a filter like the_content? if so it may not appear in previews or search snippets because:

      By default, Code Snippets executes code within your WordPress environment, but post previews and Google search snippets depend on how WordPress and search engines process content.

      1. Post previews might not fully process all filters.
      2. Google snippets are based on cached and indexed content, which may take time to update.

      A possible workaround is to ensure the tag is added directly to the post content at the time of saving using a filter like the_content

      If you want it to appear in search results, consider adding the text within the actual post content manually or using an SEO plugin to customize meta descriptions.

      Hope this helps.

      Forum: Plugins
      In reply to: [Code Snippets] & #038;
      Plugin Author Atif Riaz

      (@lightbulbman)

      Hello @developmentvict

      Thanks for raising your query,

      Can you kindly share more details or perhaps send a screen recording to our support email as I have copied your code into a new php snippet using single quotes and I had no issues to do this.

      Many thanks

      Plugin Author Atif Riaz

      (@lightbulbman)

      Hi @espressivo

      Great question! Improved error messages and handling are definitely on our roadmap, and we really appreciate your feedback. Adding the snippet ID to critical error messages is a great suggestion—we’ll take note of it as we continue refining the plugin.

      In the meantime, if you’re troubleshooting, you might find it helpful to disable snippets one by one to pinpoint the issue faster. ??

      Thanks again for sharing your thoughts!

      Best,

      Plugin Author Atif Riaz

      (@lightbulbman)

      Hey @odiez,

      Thanks for your message, at the moment the only way to do this would be in a php snippet inside a custom function however our next major feature to be released very soon will have conditions included which will allow a nice UI to apply snippets with certain conditions. I appreciate this is not available at the moment but really appreciate your patience and understanding.

      Plugin Author Atif Riaz

      (@lightbulbman)

      Hey @amandalubow ,

      Thanks for your message, does this not load on the page at all – as in the script tag does not display? I did check the link you shared and it is on the page but not sure if this is via the code snippet plugin.

      Another way and perhaps better way or more wordpress way would be to enqueue this using wordpress inbuilt wp_enqueue_script function – which is a php function and needs a php snippet – this registers the script with wordpress:

      function enqueue_cookieyes_script() { wp_enqueue_script('cookieyes', 'https://cdn-cookieyes.com/client_data/randomnumbershere/script.js', array(), null, false); } add_action('wp_enqueue_scripts', 'enqueue_cookieyes_script');

      The “false” parameter ensures it loads in the header rather than footer.

      Plugin Author Atif Riaz

      (@lightbulbman)

      @m4declare1 – Thanks for your response. To give some further context, the name attribute was one of the most requested features as an improvement to shortcodes and is only for presentation it has no impact or effect on the evaluation of the shortcode. If you have some code examples you can share either here or in a support ticket that we can test then please do share as so far I am unable to reproduce any errors. Thanks

    Viewing 15 replies - 1 through 15 (of 24 total)