Loading external post/content to a specific div (jquery, wordpress)

巧了我就是萌 提交于 2019-12-24 19:23:44

问题


I've been playing around with the grid-a-licious theme, and found some really cool sites similar to the theme: ex. http://home.visuaal.com/

The question is: any idea on how the post contents were loaded similar to the sample above?

When the user clicks on each box, the specific div expands and displays/loads the entire post. When the close button is clicked, the box returns to its normal state.

I've been figuring out how to grab the content from the post's permalink and place it in the box. I've also searched/experimented through a lot of jquery scripts but no success to make them work with wordpress.


回答1:


If you know the div that you want to load data into you can use the load function. To show and hide the div you can use one of the various Effects functions.

For example:

$("#your_div").load('/post_url', function() { 
  $(this).slideDown().click(function() { 
    $(this).slideUp();  // hide on any click - you can change the selector to suit your needs.
  });
});


来源:https://stackoverflow.com/questions/1350246/loading-external-post-content-to-a-specific-div-jquery-wordpress

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!