• Resolved regi.siti

    (@regisiti)


    I installed your snippet code for add
    Autor and update code, missed in my theme

    but i can’t undertad how use your plugin.

    in the page …./admin.php?page=add-snippet
    seams i have to add the code my self.
    where i can found the code i need??
    and why add it manually if i can add it in single.php? i can’t undertand how you plugin work,
    thanks

Viewing 7 replies - 1 through 7 (of 7 total)
  • Plugin Author Shea Bunge

    (@bungeshea)

    What sort of code are you thinking of using? Can you post an example here?

    Thread Starter regi.siti

    (@regisiti)

    I have problem whit google snippet
    – autor
    – update

    Thread Starter regi.siti

    (@regisiti)

    ther is a site whit a list of code?

    Plugin Author Shea Bunge

    (@bungeshea)

    Essentially, this plugin is designed to be used with PHP snippets that use WordPress action or filter hooks, the sort that you might put in a plugin. Generally, if you can use some code in a plugin file or in a theme’s functions.php file, it will work with this plugin.

    Hi Shea Bunge, I believe the question Regi Siti is asking is about the

    general syntax of adding the php snippet

    on a page or post.
    I personal installed this plugin on a website I am managing yesterday Sunday 6th/8/2017 but it has taken me now more than 24 hours just to figure out how to add my php snippet functionality on a specific page.

    Brief background
    I created a new snippet. I created a form that has a field which is auto-populated. I wrote some php code (new snippet created earlier) to pick the values for the auto populated field.

    My problem

    global $product;
    echo '<div class="default-btn"><a href="https://website.com/example-url/page?product-name='.urlencode(get_the_title($product->ID)).'">Recommend Product</a></div>';

    This code creates the button but the Code Snippet plugin does not show me how I can add this code to my specific page. Likewise the instructions, they don’t me how to use the plugin. Shea Bunge please help me out with this. Kindly also improve the usage instructions for the plugin.

    Thank you.

    Hi Shea Bunge, I believe the question Regi Siti is asking is about the

    general syntax of adding the php snippet

    on a page or post.
    I personal installed this plugin on a website I am managing yesterday Sunday 6th/8/2017 but it has taken me now more than 24 hours just to figure out how to add my php snippet functionality on a specific page.

    Brief background
    I created a new snippet. I created a form that has a field which is auto-populated. I wrote some php code (new snippet created earlier) to pick the values for the auto populated field.

    My problem

    global $product;
    echo '<div class="default-btn"><a href="https://website.com/example-url/page?product-name='.urlencode(get_the_title($product->ID)).'">Recommend Product</a></div>';

    This code creates the button but the Code Snippet plugin does not show me how I can add this code to my specific page. Likewise the instructions, they don’t tell me how to use the plugin. Shea Bunge please help me out with this. Kindly also improve the usage instructions for the plugin.

    Thank you.

    Plugin Author Shea Bunge

    (@bungeshea)

    Hi Michael,

    Thanks for clarifying, I think I know what the problem is now.

    The thing that it is important to understand is that this plugin is only designed to work with PHP code snippets that don’t produce direct output, but instead use actions/filters or WordPress functions. Any code that you write in a snippet should be able to be dropped in a plugin file or theme functions.php file and work without errors.

    There is a way to write a snippet which produces content in a page or post, and that is to use a shortcode. Here’s an example:

    add_shortcode( 'product-button', function () {
    
    	global $product;
    	echo '<div class="default-btn"><a href="https://website.com/example-url/page?product-name='.urlencode(get_the_title($product->ID)).'">Recommend Product</a></div>';
    
    } );
Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How edit snippet’ is closed to new replies.