Visualizzazione del contenuto del singolo post
-
-
Deviprima studiare [questo] (http://codex.wordpress.org/The_Loop)You need to study [this](http://codex.wordpress.org/The_Loop) first
- 0
- 2014-09-07
- Nilambar Sharma
-
4 risposta
- voti
-
- 2014-09-07
-
Crea unfile chiamato single.php.Questo riceverà automaticamentetuttii tuoi singolipost.Per ulterioriinformazioni sullagerarchia deimodelli di WordPress, leggiil Codex
-
All'interno di single.php,eseguiil ciclopredefinitoe ottieni header.php,sidebar.phpe footer.php
<?php get_header(); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php the_title(); ?> <?php the_content(); ?> <?php echo get_the_date(); ?> <?php endwhile; ?> <?php endif; ?> <?php get_sidebar(); ?> <?php get_footer(); ?>
Create a file named single.php. This will automatically get all you single posts. For more information about WordPress' template hierarchy, read the Codex
Inside single.php, run the default loop and get header.php, sidebar.php and footer.php
<?php get_header(); ?> <?php if (have_posts()) : while (have_posts()) : the_post(); ?> <?php the_title(); ?> <?php the_content(); ?> <?php echo get_the_date(); ?> <?php endwhile; ?> <?php endif; ?> <?php get_sidebar(); ?> <?php get_footer(); ?>
-
- 2018-03-30
puoi utilizzare lafunzione di seguitoper ottenereil contenuto delpost di Wordpress
<?php echo get_the_content(); ?>
e puoi utilizzare lafunzione di seguitoper ottenereiltitolo
<?php echo get_the_title(); ?>
per ottenere la datapuoi utilizzare questafunzione
<?php echo echo get_the_date(); ?>
you can use below function to get content of Wordpress post
<?php echo get_the_content(); ?>
and you can use below function to get title
<?php echo get_the_title(); ?>
to get date you can use this function
<?php echo echo get_the_date(); ?>
-
- 2016-11-16
function my_category_templates($single_template) { global $post; if ( in_category( 'Offers' )) { $single_template = dirname( __FILE__ ) . '/single-offer.php'; } // Copy the above for your other categories return $single_template; } add_filter( "single_template", "my_category_templates" );
function my_category_templates($single_template) { global $post; if ( in_category( 'Offers' )) { $single_template = dirname( __FILE__ ) . '/single-offer.php'; } // Copy the above for your other categories return $single_template; } add_filter( "single_template", "my_category_templates" );
-
- 2017-01-16
Usaget_post ()per ottenere unpost specifico
get_post()
Esempio:
<?php $postData = get_post( $id, $output, $filter ); echo "<pre>"; print_r($postData); ?>
https://developer.wordpress.org/reference/functions/get_post/
https://www.tipsandtricks-hq.com/query-or-show-a-specific-post-in-wordpress-php-code-example-44
Use get_post() to get specofic post
get_post()
Example :
<?php $postData = get_post( $id, $output, $filter ); echo "<pre>"; print_r($postData); ?>
https://developer.wordpress.org/reference/functions/get_post/
https://www.tipsandtricks-hq.com/query-or-show-a-specific-post-in-wordpress-php-code-example-44
Comeposso visualizzareil contenuto di un singolopost? Ilmio codice:
In
render_article
chiamosingle_post_title()
per ottenereiltitolo delpost. Tuttavianon so come ottenereiltempoe il contenuto delpostin quantonon riesco atrovare alcunafunzione comesingle_post_content()
osingle_post_time()
.