Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1298647

    Hi,

    Im using the blog element grid display. Im trying to move the date so its under the caption/excerpt. I have found a couple post about moving things around in there but I cant seem to get it working.

    Here is what im looking for.

    Image
    Exerpt
    Date

    Here is the code im using.

    function ava_move_meta_after_title(){
    ?>
     <script>
     jQuery('.slide-content').each(function(i) {
            var metaInfo = jQuery(this).find('.slide-meta');
            var postTitle =  jQuery(this).find('.entry-content-header');
            jQuery(metaInfo).insertAfter(postTitle);
           });
     </script>
    <?php
    }
    add_action('wp_footer', 'ava_move_meta_after_title');

    When adding that in I get a JS error

    Uncaught TypeError: $ is not a function
    at (index):335
    (anonymous) @ (index):335

    Can you help me out here?

    Thanks
    -Dan

    #1298649

    can you post a link to the page it concerns – or if you don’t want to make it public – is there a demo page that shows the issue?
    f.e.: https://kriesi.at/themes/enfold-2017/blog/blog-default/

    #1298651

    Here is the link.

    Is that using the blog element within the page builder or is that an archive page?

    That is exactly what im looking for.

    Thanks
    -Dan

    #1298660

    i prefere to write the whole script a $ instead of jQuery – makes some things easier to understand.

    try:

    function ava_move_meta_after_title(){ 
    ?>
    <script>
    (function($){
    	$('.slide-entry').each(function() {
    		var metaInfo = $(this).find('.slide-meta');
    		var postTitle =  $(this).find('.entry-content-header');
    		metaInfo.insertBefore($(postTitle));
    	});
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'ava_move_meta_after_title');
    #1298661

    definitly this will work too:

    function ava_move_meta_after_title(){ 
    ?>
    <script>
    (function($){
    	$('.slide-entry').each(function() {
    		var metaInfo = $(this).find('.slide-meta');
    		var postTitle =  $(this).find('.entry-content-header');
    		postTitle.insertAfter($(metaInfo));
    	});
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'ava_move_meta_after_title');
    #1298813

    Hi,

    Thanks for the help on this. Its still not working. I still get a jquery not defined error in the console.

    I edited the code also as I need the date to show up AFTER the excerpt. I think that code was trying to put it after the title. Here is what im using now but still not working.

    
    function ava_move_meta_after_title(){ 
    ?>
    <script>
    (function($){
    	$('.slide-entry').each(function() {
    		var metaInfo = $(this).find('.slide-meta');
    		var postTitle =  $(this).find('.slide-entry-excerpt');
    		metaInfo.insertAfter($(postTitle));
    	});
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'ava_move_meta_after_title');
    

    if i remove the (jQuery) part at the end I do not get that console error but still does not work.

    Thanks

    #1298941

    you have choosen to load the jQuery script in the footer ( Enfold Options – Performance – “Load jQuery in your footer” )

    so when i inspect your DOM i can see that my script is loaded before the jquery script is loaded !

    so the jQuery in my script refers to something that is not yet there.
    _________

    You can do now: change the fact that jQuery is loaded in the footer
    or try to load the custom script later

    try first:

    function ava_move_meta_after_title(){ 
    ?>
    <script>
    (function($){
    	$('.slide-entry').each(function() {
    		var metaInfo = $(this).find('.slide-meta');
    		var postTitle =  $(this).find('.entry-content-header');
    		postTitle.insertAfter($(metaInfo));
    	});
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'ava_move_meta_after_title', 999 );

    the 999 is called priority – you can see here some info: https://developer.wordpress.org/reference/functions/add_action/

    _____________________

    yes — your code then will be ok if you like to bring the date under the excerpt. – but use a priority

    • This reply was modified 3 years, 6 months ago by Guenni007.
    #1299074

    Hi,

    Thanks for helping out @guenni007, it’s much appreciated :-)

    Best regards,
    Rikard

    #1299396

    This worked! Thanks so much for helping out here.

    Thanks
    -Dan

    #1299412

    Hi Dan,

    We’re glad to hear that :)
    Thanks for using Enfold and have a great day!

    Best regards,
    Nikko

Viewing 10 posts - 1 through 10 (of 10 total)
  • The topic ‘Blog Element – Move Date Under Excerpt’ is closed to new replies.