1

When I click "read more" at the bottom of one of my website posts, it just loads the rest of the text in the same page and the same section, thus overflowing elements with text and spoiling my layout. I noticed there is a tag at the end of every Wordpress post when Read More is added from the toolbar. How can I override default behavior of this tag so that a new page is opened when a user clicks "Read More..." for a post?
Update:
I used the following code to customize the more link. However, it opens a new instance of the same page when clicked, with all posts unwrapped (I mean all posts drop their link and display all their content, thus giving a messy look to my page.
What I want is just a new completely blank page (without being affected by my theme even) where the full text of the requested post is displayed.

<?php

            add_filter( 'the_content_more_link', 'modify_read_more_link' );
            function modify_read_more_link() {
            return '<a class="more-link" target="_blank" href="' . get_permalink() . '">ادامه...</a>';
            }
            ?>
            <?php
            $cat_id=get_cat_ID('تازه ترین اخبار');
                $posts = get_posts ("cat=$cat_id&posts_per_page=1");
                if ($posts) 
            {
            foreach ($posts as $post):
                setup_postdata($post); ?>
                <h2><?php the_title(); ?></h2>
                <?php the_content();?>
                <?php endforeach;
            }
                ?>

Update:

Following the comments, I created a single.php with the following code:<br/>
<?php

get_header(); ?>

    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">
            <?php
                // Start the Loop.
                while ( have_posts() ) : the_post();


                    get_template_part( 'content', get_post_format() );



                    if ( comments_open() || get_comments_number() ) {
                        comments_template();
                    }
                endwhile;
            ?>
        </div><!-- #content -->
    </div><!-- #primary -->

<?php


get_footer();
?>

However, only the header of my site is displayed in a new page, once I click "read more" on the main page, along with a comment submit form. So the post itself is not shown. I read somewhere I could just copy and paste contents of a ready theme an Wordpress would do the rest for me. I trimmed several parts, due to raising errors, and have the code above left with the result mentioned .
Does anyone know what should I add or modify to the single.php to have each post shown completely on it with my arbitrary design? Thanks in advance enter image description here

1

It sounds like this is a problem with the way your theme is setup, since what you describe isn't the usual behaviour of the more tag. The first part of your post suggests there's some built-in Javascript in your theme causing the read more to expand the post text rather than take you to the single post page, removing that JS should solve it without any need of custom filters.

I'd also double check that your theme actually has a single.php template included, the latter part of your post suggests maybe not but this might also just be caused by the theme's JS.

  • my theme is so simple. It just contains index.php, header.php, footer.php, and images folder. I don't use any javascript except some jQuery for certain ajax calls and a simple photogallery on the main page. – codezombie Oct 20 '14 at 14:28
  • So you are missing a single.php, which is why you're seeing every post on the same page after clicking rather than just one full post. You can see the template hierarchy for a single post here codex.wordpress.org/Template_Hierarchy#Single_Post_display – Shellbot Oct 20 '14 at 14:53
0

It might be because you have left excerpt field blank. If you've out some texts (normally summary of each post) on it, it would be displayed on the page instead of full content. Please try it.

In order to know more about customizing default read more link check here

0

This stackoverflow post helped me. I added a single php with the following code that worked for me:

<?php

get_header(); ?>

    <div id="primary" class="content-area">
        <div id="content" class="site-content" role="main">         
        <?php while ( have_posts() ) : the_post(); ?>
        <h3><?php the_category('&nbsp;&rsaquo;&nbsp;'); echo "&nbsp;&rsaquo;&nbsp;"; the_title(); ?></h3>
        <?php the_content(); ?>
        <?php endwhile; // end of the loop. ?>
        </div><!-- #content -->
    </div><!-- #primary -->

<?php


get_footer();
?>

Thank you guys for the answers anyway.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.