• Hello, I am attempting to add Google Analytics tracking variables to my posts sent to Apple News using your WordPress plug-in. All of my posts are sent using the Apple News API.

    I see in the code that you allow the WordPress filter, “apple_news_markdown_hyperlink”, to alter the URL in the class-markdown.php:line 172 as part of the private parse_node_hyperlink function. Is this function/filter not used if the posts is sent via the API and published automatically?

    I have the following code in my functions.php file:

    add_filter(‘apple_news_markdown_hyperlink’, ‘my_filter_apple_news_markdown_hyperlink’);
    function my_filter_apple_news_markdown_hyperlink ( $strUrl ) {
    if(!empty($strUrl)){
    if(strpos($strUrl, ‘newTest=’) === false){
    $strUrlCancatination = (strpos($strUrl, ‘?’) === false ? ‘?’ : ‘&’);
    $strUrl = $strUrl.$strUrlCancatination.’newTest=1′;
    }
    }
    return $strUrl;
    }

Viewing 1 replies (of 1 total)
  • Thread Starter Samuel Sweitzer

    (@pooptm)

    For anyone else struggling with this, I made the following solution. WARNING: This requires editing the plug-in’s code directly, which I DO NOT recommend. But I was unable to do this any other way.

    File to edit: \wp-content\plugins\publish-to-apple-news\includes\apple-exporter\builders\class-metadata.php : line 61

    OLD CODE:

    // Add canonical URL.
    $meta[‘canonicalURL’] = get_permalink( $this->content_id() );

    NEW CODE:
    // Add canonical URL.
    $meta[‘canonicalURL’] = get_permalink( $this->content_id() );
    $meta[‘canonicalURL’] = apply_filters( ‘apple_news_markdown_hyperlink’, $meta[‘canonicalURL’] ); // add apple_news_markdown_hyperlink filter – Samuel Sweitzer 2019-07-16

Viewing 1 replies (of 1 total)

The topic ‘Post URL Filter ( )’ is closed to new replies.