Intermediary transaction http://www.aliyun.com/zixun/aggregation/6858.html ">seo diagnose Taobao guest cloud host technology Hall
Small V in helping customers develop WordPress site often encounter a variety of requirements, this time to help a customer development project, customer requirements to help him develop the site of the article can be called in other sites, and to the form of HTML to call can not use JS, said to do sprocket or something. No way the customer is God, continue to toss chant. Below the implementation method, first in the WordPress root directory to create a new html_post.php file, remember is the need to call out the WordPress site of the article. The code for the html_post.php file is as follows:
Define (' Wp_use_themes ', false);
Require ('./wp-load.php ');
Query_posts (' showposts=10&orderby=new ');
/** Charset=utf-8 "Prevent garbled * * *
< meta http-equiv= "Content-type" content= "HTML; Charset=utf-8 "/>
< PHP while (Have_posts ()): The_post ();? >
< li > < a title= "<? php the_title ();? > "href=" < php the_permalink ();? > "target=" _blank > < php the_title ();? > < a > < li >
This makes it possible to call the latest 10 articles in the Web, showposts=10 the number you want to call the article. Let me give you a detailed explanation of how to modify the code to reach the call you want to invoke the effect of the article.
1. What if I want to invoke the latest article in a category?
In fact this is very easy to implement only need to modify the query_posts this parameter, for example, I specify to call the category ID is 1 then the code becomes:
Define (' Wp_use_themes ', false);
Require ('./wp-load.php ');
/** If you want to call multiple categories at the same time separate half-width characters like cat=1,2,3,4 * *
Query_posts (' showposts=10&orderby=new&cat=1 ');
? >
/** Charset=utf-8 "Prevent garbled * * *
< meta http-equiv= "Content-type" content= "HTML; Charset=utf-8 "/>
< PHP while (Have_posts ()): The_post ();? >
< li > < a title= "<? php the_title ();? > "href=" "target=" _blank "> < php the_title ();? > < a > < li >
< PHP endwhile >
2, if I want to call the whole station Wenzhan but only to block a category under the article?
< PHP
Define (' Wp_use_themes ', false);
Require ('./wp-load.php ');
/** if you want to shield multiple categories at once, separate them with half-width characters such as Cat=-1,-2,-3,-4 * *
Query_posts (' showposts=10&orderby=new&cat=-1 ');
? >
/** Charset=utf-8 "Prevent garbled * * *
< meta http-equiv= "Content-type" content= "HTML; Charset=utf-8 "/>
< PHP while (Have_posts ()): The_post ();?>
< li > < a title= "href=" "target=" _blank "> <? php the_title ();? > < a > < li >
< PHP endwhile >
3. What if I want to call a random article?
< PHP
Define (' Wp_use_themes ', false);
Require ('./wp-load.php ');
/** if you want to shield multiple categories at once, separate them with half-width characters such as Cat=-1,-2,-3,-4 * *
Query_posts (' Showposts=10&orderby=rang ');
?>
/** Charset=utf-8 "Prevent garbled * * *
< meta http-equiv= "Content-type" content= "HTML; Charset=utf-8 "/>
< PHP while (Have_posts ()): The_post ();? >
< li > < a title= "href=" "target=" _blank "> <? PHP the_ title ()? > < a > < li >
< PHP endwhile?>
4. What if I want to output a summary?
< PHP
Define (' Wp_use_themes ', false);
Require ('./wp-load.php ');
/** if you want to shield multiple categories at once, separate them with half-width characters such as Cat=-1,-2,-3,-4 * *
Query_posts (' Showposts=10&orderby=rang ');
? >
/** Charset=utf-8 "Prevent garbled * * *
< meta http-equiv= "Content-type" content= "HTML; Charset=utf-8 "/>
< PHP while (Have_posts ()): The_post ();? >
< li > < a title= "<? php the_title ();? > "href=" "target=" _blank "> < php the_title ();? > < a >
< php echo mb_strimwidth (strip_tags apply_filters (' the_content ', $post->post_content)), 0, "...", ' utf-8 ') ; ? > < L i >
< PHP endwhile?>
Almost forgot ~ below small V to say how to call outside the station ~
< PHP
The code is placed where you want to invoke the content and list of the article
$url =http://your site address/html_post.php;
Echo file_get_contents ($url);
? >
OK, that's it. Tune out of the article are pure HTML ~ not what JS Oh, very friendly to SEO. In addition to small V hint: The method described above must be in the call site to support the case of PHP is feasible, if the call site support ASP need to read html_post.php PHP code with ASP rewrite, but if it is static space can only use JS to call slightly.