ادامه مطلب

amdh

تازه وارد
با عرض سالم و خسته نباشید

خلاصه*ای از مطلب را وارد می*کنیم و سپس با استفاده از more دکمه ادامه مطلب را ایجاد می*کنیم و پس از آن متن اصلی را وارد می*کنیم. وقتی کاربر در صفحه اصلی خلاصه را می*بیند و روی ادامه مطلب کلیک می*کند، صفحه اصلی آن مطلب باز می*شود.

مشکل آنجاست که در این صفحه، هم آن خلاصه وجود دارد و هم متن اصلی. چه کنیم که خلاصه دیگر در صفحه مخصوص آن مطلب نمایش داده نشود؟

 

caduspro

کاربر عضو
قالب چیه؟ خب هر دو کد داره فراخوانی میشه؟ نام قالب و محتوای فایل index رو اینجا قرار دهید

 

amdh

تازه وارد
ظاهرا در همه قالب*ها همینطور است. مثلا قالب 2015 خود وردپرس.

در دو عکس زیر اولین عکس در سفحه اصلی نمایش داده می*شود و عکس دوم در صفحه خود مطلب که می*خواهیم خلاصه مطلب در آن نباشد که هست.

attachment.php


attachment.php


- - - Updated - - -

این هم محتوای index

اگر می*توانید کمک کنید:

<?php

/**

* The main template file

*

* This is the most generic template file in a WordPress theme

* and one of the two required files for a theme (the other being style.css).

* It is used to display a page when nothing more specific matches a query.

* e.g., it puts together the home page when no home.php file exists.

*

* Learn more: {@link

*

* @package WordPress

* [MENTION=866]SuB[/MENTION]package Twenty_Fifteen

* [MENTION=30253]sin[/MENTION]ce Twenty Fifteen 1.0

*/

get_header(); ?>

<div id="primary" class="content-area">

<main id="main" class="site-main" role="main">

<?php if ( have_posts() ) : ?>

<?php if ( is_home() && ! is_front_page() ) : ?>

<header>

<h1 class="page-title screen-reader-text"><?php single_post_title(); ?></h1>

</header>

<?php endif; ?>

<?php

// Start the loop.

while ( have_posts() ) : the_post();

/*

* Include the Post-Format-specific template for the content.

* If you want to override this in a child theme, then include a file

* called content-___.php (where ___ is the Post Format name) and that will be used instead.

*/

get_template_part( 'content', get_post_format() );

// End the loop.

endwhile;

// Previous/next page navigation.

the_posts_pagination( array(

'prev_text' => __( 'Previous page', 'twentyfifteen' ),

'next_text' => __( 'Next page', 'twentyfifteen' ),

'before_page_number' => '<span class="meta-nav screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>',

) );

// If no content, include the "No posts found" template.

else :

get_template_part( 'content', 'none' );

endif;

?>

</main><!-- .site-main -->

</div><!-- .content-area -->

<?php get_footer(); ?>

You must be registered for see images attach


You must be registered for see images attach


 

caduspro

کاربر عضو
خب محتوای فایل content رو قرار بده. از اونجا فراخوانی میشه

 

amdh

تازه وارد
اینم محتوای کانتنت:


کد:
<?php
/**
 * The default template for displaying content
 *
 * Used for both single and index/archive/search.
 *
 * @package WordPress
 * [MENTION=866]SuB[/MENTION]package Twenty_Fifteen
 * [MENTION=30253]sin[/MENTION]ce Twenty Fifteen 1.0
 */
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php
        // Post thumbnail.
        twentyfifteen_post_thumbnail();
    ?>

    <header class="entry-header">
        <?php
            if ( is_single() ) :
                the_title( '<h1 class="entry-title">', '</h1>' );
            else :
                the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
            endif;
        ?>
    </header><!-- .entry-header -->

    <div class="entry-content">
        <?php
            /* translators: %s: Name of current post */
            the_content( sprintf(
                __( 'Continue reading %s', 'twentyfifteen' ),
                the_title( '<span class="screen-reader-text">', '</span>', false )
            ) );

            wp_link_pages( array(
                'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfifteen' ) . '</span>',
                'after'       => '</div>',
                'link_before' => '<span>',
                'link_after'  => '</span>',
                'pagelink'    => '<span class="screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>%',
                'separator'   => '<span class="screen-reader-text">, </span>',
            ) );
        ?>
    </div><!-- .entry-content -->

    <?php
        // Author bio.
        if ( is_single() && get_the_author_meta( 'description' ) ) :
            get_template_part( 'author-bio' );
        endif;
    ?>

    <footer class="entry-footer">
        <?php twentyfifteen_entry_meta(); ?>
        <?php edit_post_link( __( 'Edit', 'twentyfifteen' ), '<span class="edit-link">', '</span>' ); ?>
    </footer><!-- .entry-footer -->

</article><!-- #post-## -->
 

caduspro

کاربر عضو
خب مشکل این بود که چکیده نوشته هم در برگه single هم نمایش داده میشد. الان این قالب محتوای نمایشی رو از یک فایل فراخوانی می کنه. برای اینکه ساده بگم:

1. یک فایل جدید php ایجاد کن.

2. این محتوا رو داخلش قرار بده:


کد:
<?php
/**
 * The default template for displaying content
 *
 * Used for both single and index/archive/search.
 *
 * @package WordPress
 *  [MENTION=866]SuB[/MENTION]package Twenty_Fifteen
 *  [MENTION=30253]sin[/MENTION]ce Twenty Fifteen 1.0
 */
?>

<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php
        // Post thumbnail.
        twentyfifteen_post_thumbnail();
    ?>

    <header class="entry-header">
        <?php
            if ( is_single() ) :
                the_title( '<h1 class="entry-title">', '</h1>' );
            else :
                the_title( sprintf( '<h2 class="entry-title"><a href="%s" rel="bookmark">', esc_url( get_permalink() ) ), '</a></h2>' );
            endif;
        ?>
    </header><!-- .entry-header -->

    <div class="entry-content">
        <?php
            /* translators: %s: Name of current post */
            the_content();

            wp_link_pages( array(
                'before'      => '<div class="page-links"><span class="page-links-title">' . __( 'Pages:', 'twentyfifteen' ) . '</span>',
                'after'       => '</div>',
                'link_before' => '<span>',
                'link_after'  => '</span>',
                'pagelink'    => '<span class="screen-reader-text">' . __( 'Page', 'twentyfifteen' ) . ' </span>%',
                'separator'   => '<span class="screen-reader-text">, </span>',
            ) );
        ?>
    </div><!-- .entry-content -->

    <?php
        // Author bio.
        if ( is_single() && get_the_author_meta( 'description' ) ) :
            get_template_part( 'author-bio' );
        endif;
    ?>

    <footer class="entry-footer">
        <?php twentyfifteen_entry_meta(); ?>
        <?php edit_post_link( __( 'Edit', 'twentyfifteen' ), '<span class="edit-link">', '</span>' ); ?>
    </footer><!-- .entry-footer -->

</article><!-- #post-## -->
3. فایل single رو باز کن و در قسمت زیر بجای content نام فایل جدیدی که ساختی رو قرار بده.


کد:
get_template_part( 'content', get_post_format() );
بعد آزمایش کن و خبرش رو بهم بده.

 

amdh

تازه وارد
این کاری که گفتید را انجام دادم ولی

وقتی نام فایل را با پسوند پی اچ پی به جای content می*ذارم هیچی نشون نمی*ده

attachment.php


attachment.php


وقتی هم بدون پسوند پی اچ پی می*ذارم هیچ فرقی نداره و هم خلاصه مطلب رو نشون می*ده هم مطلب اصلی رو.

attachment.php


attachment.php


- - - Updated - - -

این هم فایل پی اچ پی که گفتید بسازم.

You must be registered for see images attach


You must be registered for see images attach


You must be registered for see images attach


You must be registered for see images attach




 

پیوست‌ها

  • content-test.rar
    820 بایت · بازدیدها: 0

caduspro

کاربر عضو
نباید مشکلی باشه. این کد رو آزمایش کنید (در فایل حدید که ساختید:


کد:
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    <?php
        // Post thumbnail.
        twentyfifteen_post_thumbnail();
    ?>

    <header class="entry-header">
       <h1 class="entry-title"> <?php the_title(); ?></h1>
    </header><!-- .entry-header -->

    <div class="entry-content">
        <?php the_content(); ?>
    </div><!-- .entry-content -->

    <?php
        // Author bio.
        if ( is_single() && get_the_author_meta( 'description' ) ) :
            get_template_part( 'author-bio' );
        endif;
    ?>

    <footer class="entry-footer">
        <?php twentyfifteen_entry_meta(); ?>
        <?php edit_post_link( __( 'Edit', 'twentyfifteen' ), '<span class="edit-link">', '</span>' ); ?>
    </footer><!-- .entry-footer -->

</article><!-- #post-## -->
اگر کار نکرد، بگید تا خودم در لوکال آزمایش کنم

 

amdh

تازه وارد
خیلی ممنون به خاطر زحماتتون.

بازم کار نکرد و فرقی نداشت.

ببخشید چند روزی نیستم.

 
بالا