Home  >  Article  >  CMS Tutorial  >  How to call an article from another website in wordpress

How to call an article from another website in wordpress

尚
Original
2019-07-20 10:25:403536browse

How to call an article from another website in wordpress

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(&#39;WP_USE_THEMES&#39;, false);
require(&#39;./wp-load.php&#39;);
query_posts(&#39;showposts=1&#39;);
?>
<?php while (have_posts()): the_post(); ?>
<li><a href="<?php the_permalink(); ?>" target="_blank"><?php echo mb_strimwidth(strip_tags(apply_filters(&#39;the_title&#39;,$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="//m.sbmmt.com/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!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn