• Resolved Sébastien SERRE

    (@sebastienserre)


    Hello,
    In a custom dev I retrieve the latest download with:

    		$actus_new = get_posts(
    			array(
    				'post_type'      => array(
    					'post',
    					'dlm_download'
    				),
    				'posts_per_page' => - 1,
    				'order_by'       => 'date',
    				'order'          => 'DESC',
    				'date_query'     => array(
    					array(
    						'after' => '2 months ago'
    					)
    				)
    			)
    		);

    And later in my templates, I’m creating a link as follow:

    foreach ( $actus_new as $actu ) { ?>
                               <li>
                                <span class="dashicons dashicons-<?php echo $dashicons; ?> >"></span>
                                <a href="<?php echo get_the_permalink( $actu->ID ) ?>"><?php echo $actu->post_title; ?></a>
                            </li>
    <?php
    }

    The permalink created was OK with Download Monitor 4.7.75. By upgrading to 4.7.78 (it breaks at 4.7.76), all the permalink are the same…

    I’m on WP6.2

    —– Edit Message —
    The issue comes from the filter wp-content/plugins/download-monitor/src/DLM.php:251

    
    		// Get the correct download link in archive pages or when retrieving download permalink
    		add_filter( 'post_type_link', array( $this, 'archive_filter_download_link' ), 20, 2 );

    Did you change something in the latest version inside ?

    	public function archive_filter_download_link( $post_link, $post ) {
    
    		// We exclude the search because there is a specific option for this
    		if ( 'dlm_download' == $post->post_type && ! is_search() ) {
    			if ( ! isset( $GLOBALS['dlm_download'] ) ) {
    				// fetch download object
    				try {
    					/** @var DLM_Download $download */
    					$download                = download_monitor()->service( 'download_repository' )->retrieve_single( $post->ID );
    					$GLOBALS['dlm_download'] = $download;
    
    					return $download->get_the_download_link();
    				} catch ( Exception $e ) {
    				}
    			} else {
    				return $GLOBALS['dlm_download']->get_the_download_link();
    			}
    		}
    
    		return $post_link;
    	}
    • This topic was modified 1 year, 8 months ago by Sébastien SERRE. Reason: Add debug info
Viewing 4 replies - 1 through 4 (of 4 total)
Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Permalink broken’ is closed to new replies.