• I’m trying to write a plugin, and as I develop, one of the things I need to do is to print the https://rvtechsolutions.com/wp-content/uploads/2013/06/Change-URL1.jpg permalink preview to the console. I have tried the functions get_sample_permalink_html, get_permalink, get_preview_post_link, and I cannot get ANYTHING to print to the error log. I’ve tried using $post, $post_ID, and others as parameters. The plugin runs as a metabox on post.php.

    How can I achieve this?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter bullshark

    (@bullshark)

    I’ve tried

    I’ve done:

        $printedURL = get_sample_permalink_html($post);
        error_log(print_r($printedURL,true));
    
    	$printedURL2 = wp_ajax_sample_permalink();
    	error_log(print_r($printedURL2,true));
    
        require_once( ABSPATH . 'wp-admin/includes/post.php' );
     	$permalink = get_sample_permalink_html( $post->ID, $post->title, $post->$slug );
        error_log(print_r($permalink,true));
    
        $permalink = get_sample_permalink_html( $post->ID );
    	error_log(print_r($permalink,true));
    
        $permalink = get_preview_post_link( $post );
    	error_log(print_r($permalink,true));
    
        $permalink = get_permalink( $post_ID );
    	error_log(print_r($permalink,true));
    
        require_once ABSPATH . '/wp-admin/includes/post.php';
        error_log(print_r(get_sample_permalink_html( $post_id, $title, $slug ),true));
    
        require_once ABSPATH . '/wp-admin/includes/post.php';
        error_log(print_r(get_sample_permalink_html( $post->ID, $post->post_title),true));
    
        error_log(print_r(get_sample_permalink(),true));

    and none of these have worked.

    Moderator bcworkz

    (@bcworkz)

    Hiya bullshark. It’s not clear in what context your attempts execute. You’d want to utilize a filter hook to log information when a WP function executes. For example:

    add_filter('get_sample_permalink', function( $link ) {
    	error_log( print_r( $link, true ));
    	return $link;
    });

    Add to your plugin somewhere where it’ll execute when the plugin loads. Note that this logs entries to your server’s error log file. It does not go to your browser console. If you really want to log to the console, you’ll need an admin JS script that extracts the link from the page’s DOM and then logs to console with console.log()

    BTW, I’ve removed your account here from moderation watch. You’ll be able to post without delay again. Please be sure you no longer post duplicate topics anywhere on www.ads-software.com.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Getting the sample permalink to print to error_log’ is closed to new replies.