Provide zblog template_zblog them_wordpress template download and customization

Wordpress calls the title, link, alias, article, etc. of the specified category

Tianxing Studio 2019-12-20 13:59 Wordpress Tutorial three thousand one hundred and eighty-three 0 Comments


wordpress When developing topics, we often encounter calls to the title, link, alias, etc. of the specified category. Wordpress has no ready-made tags but functions. This article will share Wordpress call Specify how to use the title, link, alias, and article of the category.

Call the title of the specified category:

 <? php echo get_cat_name(1);?>

Call the link of the specified classification:

 <? php echo get_category_link(1);  ?>

Call the alias of the specified classification:

 <? php $cat = get_category(1); echo $cat->slug;?>

Call the latest article of the specified category:

 <? php query_posts('cat=1&showposts=8');  ?> <? php while (have_posts()) : the_post();  ?> <li><a href="<?php the_permalink(); ?>"><? php the_title();?></ a></li> <? php endwhile;  wp_reset_query();  ?>

The number "1" in the above code is the classification id to be called, and the number 8 is the number of articles to be called.


Can't find a tutorial that can solve your problem?

You can try to search or ask questions directly online. We also provide charging technical support. If you need it, you can contact us online.

Online questions Online Service

welcome you Comment: Cancel Reply

 Please fill in the verification code
  • Latest articles
  • Hot article ranking
  • Most Comments
Label aggregation
  • Sign in
  • Registered account Forgot your password?
  • register
  • Already have an account? Direct login Forgot your password?
  • Social account login