Viewing 30 posts - 31 through 60 (of 61 total)
  • Author
    Posts
  • #1301395

    Thanks Guenni!

    It works perfectly, except for the date .. I have changed the date of this: “Kampagne: Telmore Play med TV2 og Viaplay til 129 kr. første måned”.

    #1301398

    i started a question on support forum of pum
    i do not know why the code ( get_the_date) does not take the publishing date of the popup but only from the page where it is opened.

    #1301400

    Oh super! I hope they know why ..

    And sorry, but is it possibe to make the date shown as xx.xx.xx. Instead of the full month and year – it takes a lot of space

    #1301472

    Now let’s check the feasibility first, and then do the styling.
    if you takte this as shortcode :

    function shortcode_for_publishing_date_of_posts(){
     	return get_the_date( 'd.m.Y', get_the_ID($post->ID) );
    }
    add_shortcode( 'post_published', 'shortcode_for_publishing_date_of_posts' );

    but it is alway the publishing date of the page where the popup is placed

    but there must be a possibility, because when I look at a blog page from Enfold, there is also the publishing time of the single blog page displayed and not that of the blog page.
    I hope a mod can answer this question, because I have to take care of my business now.

    #1301517

    Till a solution is found you can place the publishing date manually to your popups as:

    
    <span class="date-published">xx.xx.2021</span>

    The date will than be inserted automatically to your list.

    See here : https://wordpress.org/support/topic/echo-get_the_date-in-popup-window/

    #1301583

    Guenni, YOU ARE THE BEST! Thank you so much for all the time you have used! I am very grateful.

    #1301591

    Hi,

    Thanks for helping out @guenni007 :-)

    Best regards,
    Rikard

    #1302576

    here is the solution to it:

    remove the shortcode function so that you only have on child-theme functions.php:

    
    // this is now the code to insert the popup publishing date - 
    // all credits goes to a guy that helped me from wp-popupmaker : Mark Chaves !
    function add_date_time_popup_content( $content ) {
    	if ( ! function_exists( 'pum_get_popup_id' ) ) return;
    	$popup_id = pum_get_popup_id();
    	return "<p class='date-published'>" . get_the_date( 'd.m.Y' , $popup_id ) . "</p>" . $content  ;
    }
    add_filter( 'pum_popup_content', 'add_date_time_popup_content' );
    
    //-----------------
    // this is the known script
    function show_date_of_popup(){
    ?>
    <script type="text/javascript">	
    (function($) {
    	$(document).ready(function(){ 	  
    		$('.pum-trigger').each(function() {
    			var pumPopup = $('.pum').css('display');
    			var trigger_name = $(this).attr('class').split(' ')[0];
    			var publishingDate = $(this).closest('#top').find('#'+trigger_name+' .date-published').text();
    			var date_published = $('<span class="puplished">'+publishingDate+'</span>');
    			$(this).append(date_published);	
    		});
    	});	
    })(jQuery);	       
    </script>
    <?php
    }
    add_action('wp_footer', 'show_date_of_popup', 9999);
    #1302596

    Hello Guenni,

    Thanks for getting back :)

    I have replaced the other code with the new, and removed the shortcode from two of the popups, but I can seem to make it work on my end.

    • This reply was modified 3 years, 5 months ago by Telmore.
    #1302604

    yes sorry – on my testinstallation i have first the pum-trigger class than the id
    so i corrected the second code to split on [0]
    ( var trigger_name = $(this).attr('class').split(' ')[0]; this is different to my installation – you had to take the first part of the class list )

    replace it

    #1302605

    I am not sure what you mean? Sorry.

    #1302606

    on your triggers : you have the classes ( f.e.)
    popmake-21659 pum-trigger

    on my testinstallation i would have:
    pum-trigger popmake-21659

    we need that popmake-21659

    so just replace the whole code by:

    // this is now the code to insert the popup publishing date - 
    // all credits goes to a guy that helped me from wp-popupmaker : Mark Chaves !
    function add_date_time_popup_content( $content ) {
    	if ( ! function_exists( 'pum_get_popup_id' ) ) return;
    	$popup_id = pum_get_popup_id();
    	return "<p class='date-published'>" . get_the_date( 'd.m.Y' , $popup_id ) . "</p>" . $content  ;
    }
    add_filter( 'pum_popup_content', 'add_date_time_popup_content' );
    
    //-----------------
    // this is the known script
    function show_date_of_popup(){
    ?>
    <script type="text/javascript">	
    (function($) {
    	$(document).ready(function(){ 	  
    		$('.pum-trigger').each(function() {
    			var pumPopup = $('.pum').css('display');
    			var trigger_name = $(this).attr('class').split(' ')[0];
    			var publishingDate = $(this).closest('#top').find('#'+trigger_name+' .date-published').text();
    			var date_published = $('<span class="puplished">'+publishingDate+'</span>');
    			$(this).append(date_published);	
    		});
    	});	
    })(jQuery);	       
    </script>
    <?php
    }
    add_action('wp_footer', 'show_date_of_popup', 9999);
    #1302607

    this in the code above

    
    var trigger_name = $(this).attr('class').split(' ')[0]

    will search for the classes – split the class list on spaces and will take the first class ( it starts at 0 )

    this is what i got on the test:
    ( click to enlarge )

    i got the id at the second position !

    #1302610

    ok – you got it now
    But – now you have to remove in your popups the shortcode :

    <span class="date-published">[post_published]</span>
    

    if you do not want to show the published date in the popups content – you can hide it there.
    or you can shift it to the bottom of the popup content.

    #1302611

    It worked :)

    – but is it possible to have the week day too?

    #1302613

    I will remove all of the shortcodes in the popups – thanks :)

    #1302614

    first you told me it is too long!

    Replace the part of the function above:

    function add_date_time_popup_content( $content ) {
    	if ( ! function_exists( 'pum_get_popup_id' ) ) return;
    	$popup_id = pum_get_popup_id();
    	return "<p class='date-published'>" . get_the_date( 'l, d.m.Y' , $popup_id ) . "</p>" . $content  ;
    }
    add_filter( 'pum_popup_content', 'add_date_time_popup_content' );

    that part: ‘l, d.m.Y’ is responsible for it:
    see here foramting options: https://wordpress.org/support/article/formatting-date-and-time/

    • This reply was modified 3 years, 5 months ago by Guenni007.
    #1302619

    But think of – you want the publishing date of the popup to show – i can see now different manual dates on that:

    https://kriesi.at/support/topic/date-appearance-in-text-box/page/2/#post-1301398

    #1302622

    Sorry – my boss preferred this. Thanks :)

    #1302627

    if you like to have some binding words in that date do it this way:
    The backslash will show the code that it does not stand for the day but to have text here

    'l \d. d.m.Y'
    
    #1302633

    Hi Guenni,
    I think it looks just perfect right now!
    Again, thanks a lot!

    #1302807

    Hello Guenni,

    I am back. How do i make the initial of the week day big (CAPS)?

    And is it also possible to show the date on the third text box? There is no popups, only links.

    Thanks in advance!
    Best regards Sheila

    #1302932

    But this does not belong to the code i gave to you.
    What do you see if you go to dashboard – general – Date Format : if you choose custom and put in : l \d. d.m.Y on preview:
    ________

    you see here that the normal format is for Weekday a capitalized result.
    btw: you don’t want all letters uppercase – just the first one?

    #1302934

    we can surround the weekday by some html with a class. Those extra letters had to be escaped.

    Replace the whole code with:

    function add_date_time_popup_content( $content ) {
    	if ( ! function_exists( 'pum_get_popup_id' ) ) return;
    	$popup_id = pum_get_popup_id();
    	return "<p class='date-published'>" . get_the_date( '\<\s\p\a\n \c\l\a\s\s\=\"\w\e\e\k\d\a\y\"\> l \<\/\s\p\a\n\> \d. d.m.Y' , $popup_id ) . "</p>" . $content  ;
    }
    add_filter( 'pum_popup_content', 'add_date_time_popup_content' );
    
    function show_date_of_popup(){
    ?>
    <script type="text/javascript">	
    (function($) {
    	$(document).ready(function(){ 	  
    		$('.pum-trigger').each(function() {
    			var pumPopup = $('.pum').css('display');
    			var trigger_name = $(this).attr('class').split(' ')[0];
    			var publishingDate = $(this).closest('#top').find('#'+trigger_name+' .date-published').html();
    			var date_published = $('<span class="puplished">'+publishingDate+'</span>');
    			$(this).append(date_published);	
    		});
    	});	
    })(jQuery);	       
    </script>
    <?php
    }
    add_action('wp_footer', 'show_date_of_popup', 9999);

    and put this to quick css:

    .puplished .weekday,
    .date-published .weekday {
    	text-transform: capitalize;
    }
    #1303128

    Hi Guenni,

    That worked perfect! thanks! :)

    – And was it also possible to show the date on the third text box? There is no popups, only links. The one called “Opdateringer på Telman”.

    Thanks in advance.

    #1303135

    *I see now that this has created another issue – the date wants to be shown on every popups on the whole site. See example in the footer :(

    • This reply was modified 3 years, 5 months ago by Telmore.
    #1303258

    Oh, come on now – you should be able to provide a little of your own effort and, above all, transfer performance!

    make the selector more specific.
    if there is $('.pum-trigger').each(function() { – this will influence all elements with “pum-trigger” class.
    you can give to those columns f.e. a custom class – or to the color-sections etc. pp.
    if it is only on that page ( page id : 7) and in that color-section etc etc.

    $('#top.page-id-7 #av_section_2 .pum-trigger').each(function() {

    the first snippet is untouched of that – so in the popup there will be the date.
    But the transfer to the trigger is only on those more specific selected elements.

    #1303617

    – And was it also possible to show the date on the third text box? There is no popups, only links. The one called “Opdateringer på Telman”.

    #1304727

    Hi Sheila,

    Sorry for the late reply!

    I wanted to look into it however logins did not work for me. Do you still need assistance? :)

    Best regards,
    Yigit

    #1304862

    Hi Yigit,

    No it is fine, but thank you very much. You are welcome to close this topic :)

    – Sheila

Viewing 30 posts - 31 through 60 (of 61 total)
  • The topic ‘Date appearance in text box’ is closed to new replies.