• Resolved idealmin

    (@idealmin)


    Hi there. I’m wanting to use this theme with MyArcadePlugin. But I need to enter some code into single.php within the WordPress loop.

    Usually this might be quite simple but your themes single.php uses a lot of custom codexes or something?

    Anyway I need to enter this code into single.php

    <?php
    if (function_exists(‘get_game’)) {
    /* mypostid global is needed for MyScoresPresenter */
    global $mypostid; $mypostid = $post->ID;
    echo myarcade_get_leaderboard_code();
    echo get_game($post->ID);
    }
    ?>

    As explained here http://myarcadeplugin.com/documentation/developer-guide/#get_game

    But having some issue locating the right bit to edit/change.

    Could you kindly assist me in this matter?

    I hope.

    Regards.

    Mike.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author nobita

    (@nobita)

    Hi idealmin

    Without customizing the template, in a specific location, Raindrops theme, you can insert a template part file and code

    For example

    Add to code with action hook.

    add_action( 'raindrops_append_entry_content', 'your_function' );
    
    function your_function(){
    	global $post;
    
    	if ( is_single() && function_exists( 'get_game' ) ) {
    
    		/* mypostid global is needed for MyScoresPresenter */
    
    		global $mypostid; $mypostid = $post->ID;
    		echo myarcade_get_leaderboard_code();
    		echo get_game($post->ID);
    	}
    }

    Using Template part file.

    Create a template name hook-append-entry-content.php

    global $post;
    
    	if ( is_single() && function_exists( 'get_game' ) ) {
    
    		/* mypostid global is needed for MyScoresPresenter */
    
    		global $mypostid; $mypostid = $post->ID;
    		echo myarcade_get_leaderboard_code();
    		echo get_game($post->ID);
    	}

    How to find action hooks and template name.

    1. Open wp-config.php and WP_DEBUG value set true.

    2. Open raindrops/functions.php or childthemes/functions.php
    when parent theme functions.php first line <?php before.

    <?php
      $raindrops_actions_hook_message = true;
    ?>

    3. Open your blog and shows single.php

    When you are finished, please undo the changes always

    Thank you.

    Theme Author nobita

    (@nobita)

    Since there is no reply 2 weeks, change to Resolved

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Add custom code to wordpress loop?’ is closed to new replies.