Forum Replies Created

Viewing 5 replies - 1 through 5 (of 5 total)
  • Thread Starter jonathan1138

    (@jonathan1138)

    Ah, I did spot that but thought I had replaced the quotes, evidently I missed some. Btw those were copied directly from here so I blame this website for quote misrepresentation! ??

    Thanks, it’s working now.

    Thread Starter jonathan1138

    (@jonathan1138)

    I used one of the existing templates for my code, I’ve just been struggling with the date part. Here is my code:

    <?php
    /**
     * Shows date and title only.
     */
    
    if ( ! defined( 'ABSPATH' ) ) {
    	exit;
    } // Exit if accessed directly
    
    ?>
    <?php 
    
    echo date(“Y-m-d”,$dlm_download->get_version()->get_date()->format( ‘U’ ));
    
    ?><a class="download-link" title="<?php if ( $dlm_download->get_version()->has_version_number() ) {
    	printf( esc_html__( 'Version %s', 'download-monitor' ), esc_html( $dlm_download->get_version()->get_version_number() ) );
    } ?>" href="<?php esc_url( $dlm_download->the_download_link() ); ?>" rel="nofollow">
    	<?php $dlm_download->the_title(); ?>
    </a>

    I expect the date to be printed and then the filename (it will look prettier once I get the date part working). I don’t need a button, just a text link over the document name, that part is working fine. Using this template outputs nothing where the date should be, I have confirmed that this is the template in use by adding other echo parts after the date echo line.

    • This reply was modified 2 years, 7 months ago by jonathan1138.
    Thread Starter jonathan1138

    (@jonathan1138)

    Thank you for your reply f2065, however I can’t get that code to work. While attempting to debug, I noted that the first echo outputs nothing, the second echo throws an error.

    I have been scouring the documentation but can find no mention of
    get_version()->get_date()
    or any other method to get the date, only shortcode filters which is not useful to me I think.

    • This reply was modified 2 years, 7 months ago by jonathan1138.
    Thread Starter jonathan1138

    (@jonathan1138)

    Thank you! add_query_arg() certainly put me on the right track.

    FWIW I had to make use of the additional function shown on the get_query_var() for custom query vars, shown on this page (added to my functions.php).

    My button link looks like this:
    <a href="<?php echo esc_url( add_query_arg('category',$value) ); ?>"><?php echo $label; ?></a>

    So I can then get the custom query var like this:
    $sub_category = get_query_var( 'category' );

    Thread Starter jonathan1138

    (@jonathan1138)

    Arrrgh! Just looked at the code and saw the extra closing div sitting further down (was supposed to have been commented out). At least now I know this method works for an overlay image!

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