When we are making a wordpress theme, we want to specifically display articles under a certain category in the author's website in a certain location in the theme settings; or we want to call another one in a website How should we operate an article in a wordpress website?
Implementation method:
Then we first need to create a new call.php file in the root directory of the called wordpress website. The specific file name can be Modify it arbitrarily, and then put the following code into it. Note that it is uft-8 no B mode.
<?php define('WP_USE_THEMES', false); require('./wp-load.php'); query_posts('showposts=1'); ?> <?php while (have_posts()): the_post(); ?> <li><a href="<?php the_permalink(); ?>" target="_blank"><?php echo mb_strimwidth(strip_tags(apply_filters('the_title',$post->post_title)), 0, 50," "); ?></a></li> <?php endwhile; ?>
query_posts(\'showposts=10\'); in the above code can be modified by yourself, specifically The modification method varies depending on the WordPress theme and plugin used. Where you need to call (requires php support), add the following code:
<?php $url="https://www.php.cn/call.php"; echo file_get_contents( $url ); ?>
Replace the above URL with your own!
For more wordpress related technical articles, please visit the wordpress tutorial column to learn!
The above is the detailed content of How to call an article from another website in wordpress. For more information, please follow other related articles on the PHP Chinese website!