• Resolved Francisco

    (@ffsantosjr)


    Hello all,

    I am trying to figure out how to make a sliding read more to work with wordpress. My theme is Customizr.

    The code is saved on fiddle: https://jsfiddle.net/o7x14gzd/

    I tested there and it’s working, but I can’t put it to work on wordpress.

    Can you help me how to?

    Thanks!

Viewing 8 replies - 1 through 8 (of 8 total)
  • You can’t use jquery shorthand in WordPress – for example – $(this).outerHeight(); has to be jQuery(this).outerHeight();

    Thread Starter Francisco

    (@ffsantosjr)

    Hi cukeving, thank you for replying.

    Looking at the code, I have changed but I still cannot have the funcionality. Could you tell me which parts would you change in that script to get it working on wordpress?

    Thanks in advance,

    I’m not an expert – i think there were only 3 places in your code that needed changing:

    var $el, $ps, $up, totalHeight;

    jQuery(“.sidebar-box .button”).click(function() {

    totalHeight = 0

    $el = jQuery(this);
    $p = $el.parent();
    $up = $p.parent();
    $ps = $up.find(“p:not(‘.read-more’)”);

    // measure how tall inside should be by adding together heights of all inside paragraphs (except read-more paragraph)
    $ps.each(function() {
    totalHeight += jQuery(this).outerHeight();
    });

    $up
    .css({
    // Set height to prevent instant jumpdown when max height is removed
    “height”: $up.height(),
    “max-height”: 9999
    })
    .animate({
    “height”: totalHeight
    });

    // fade out read-more
    $p.fadeOut();

    // prevent jump-down
    return false;

    });

    It would also help if you could post a link to a page that shows the issue.

    Thread Starter Francisco

    (@ffsantosjr)

    Hi stephencottontail,

    I got it from here: https://css-tricks.com/text-fade-read-more/

    And there is a demo here:
    https://css-tricks.com/examples/ReadMoreFade/

    Thread Starter Francisco

    (@ffsantosjr)

    Hi cukeving, thanks! But tested in my website and still behaves as I don’t have any script.

    But it’s okay, even though I think it’s strange how there are no actual plugins for this.

    Sorry, I wanted you to post a link to a page on your site that isn’t working correctly. How are you adding the script to your site?

    Thread Starter Francisco

    (@ffsantosjr)

    Hi stephencottontail. I just discovered that was because my wordpress instalation was not calling jquery so the function did not work properly.
    It was in my local test server.
    As I don’t know yet how to call only on posts and pages I put the jquery calling it inside a widget with condition of visibility for pages and posts, and the css inside my child theme style.css. The only thing I need to do is to open that div and put the text inside :).

    Thank you for helping me.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Insert a Read More with jQuery’ is closed to new replies.