Setting up a simple WordPress blog, that only contains a single page wich is the blog archive. But i have run in to a problem, i want to have a toggle the excerpt and content show more/show less functionality, så that visitors easy can go trough the posts on the same page without page reloads or beeing sent to the single post page. I know this has been asked here before but none of those examples works for me. Just want a simple show/hide functionality to show the excerpt automatic and when users click show more, the whole post slides open to show complete content, and when they click show less, the post goes back to excerpt. I tried most that is here on stack but nothingworks so now i rolled back to my original files to start over. So this script does nothing right now as you se in the loop-custom file. But this is what i have tried.
Here is my js:
$(function () {
$('.mainContent').hide();
$('a.read').click(function () {
$(this).parent('.excerpt').slideUp('fast');
$(this).closest('.post').find('.mainContent').slideDown('fast');
// $('.mainContent').show();
return false;
});
$('a.read-less').click(function () {
$(this).parent('.mainContent').slideUp('fast');
$(this).closest('.post').find('.excerpt').slideDown('fast');
return false;
});
});
Here is my index file:
<div id="content">
<div id="inner-content" class="row">
<main id="main" class="large-8 medium-8 columns" role="main">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<!-- To see additional archive styles, visit the /parts directory -->
<?php get_template_part( 'parts/loop', 'custom' ); ?>
<?php endwhile; ?>
<?php joints_page_navi(); ?>
<?php else : ?>
<?php get_template_part( 'parts/content', 'missing' ); ?>
<?php endif; ?>
</main> <!-- end #main -->
<?php get_sidebar(); ?>
</div> <!-- end #inner-content -->
</div> <!-- end #content -->
And here is my loop-custom file:
<article class="post" id="post-<?php the_ID(); ?>" <?php post_class(''); ?> role="article">
<header class="article-header">
<?php get_template_part( 'parts/content', 'byline' ); ?>
<h2><?php the_title(); ?></h2>
</header> <!-- end article header -->
<section class="entry-content" itemprop="articleBody">
<a href="<?php the_permalink() ?>"><?php the_post_thumbnail('full'); ?></a>
<?php the_excerpt('<button class="tiny">' . __( 'Show more...', 'jointswp' ) . '</button>'); ?>
</section> <!-- end article section -->