用什么wordpress函数来控制Admin中的主题

时间:2017-01-17 18:09:11

标签: wordpress wordpress-theming

我正在创建我的第一个Wordpress主题,最初我想了解如何在admin中控制index.php?

<h3>Service<h3>
<img src="<?php bloginfo ('template_directory'); ?>/img/iamgeservice1.png" class="img-responsive" alt="">

<h3>Service 2<h3>
<img src="<?php bloginfo ('template_directory'); ?>/img/imageservice2.png" class="img-responsive" alt="">

如果每个服务都是一个页面或帖子,并在index.php中仅显示标题和突出显示的图像。

仅显示所选的服务(页面或帖子)

我应该在function.php中使用什么Wordpress函数?

1 个答案:

答案 0 :(得分:3)

根据我的理解,您只想在主页/ index.php文件中显示服务。

创建用于添加服务的帖子类型: 使用此插件创建新的帖子类型 https://wordpress.org/plugins/custom-post-type-ui/ 或使用https://codex.wordpress.org/Function_Reference/register_post_type

您可以使用以下查询显示内容,更改帖子类型名称

[
 {
"id": 479,
"date": "2016-12-30T13:55:16",
"date_gmt": "2016-12-30T13:55:16",
"guid": {
  "rendered": "http://www.mytrendin.com/?p=479"
},
"modified": "2016-12-30T14:01:28",
"modified_gmt": "2016-12-30T14:01:28",
"slug": "increase-child-development",
"type": "post",
"link": "http://www.mytrendin.com/increase-child-development/",
"title": {
  "rendered": "How to increase your children capabilities ?"
},
"content": {
  "rendered": "<div dir=\"auto\">Child development | How fast your child will be, it depends on you too much. What methods are you going to apply on them? This is overall your duty. A child spends his time at home as compared to school two times faster. Most children spend their time to watch TV and playing games on mobile phones. In a research, it is proved that approximately 80 present brain development complete up-to the age of 8 years. Important parts of the brain develop up-to-the stage, when your child is 8 years. The direct connection of this brain development depends on your child daily activities. If you are aware of your child activities than you total control is in your hand.</div>\n<div dir=\"auto\">Here are some tips which definitely help you to increase your children capabilities.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\"><strong>1. Do parenting in the right direction:</strong> it is considered most frequently that to fulfilled their all demands, keep them in discipline, give them moral values, these all are signs of good parenting. But good parenting is more than this. Good parenting means to completely develop your child capabilities. So he can achieve that target that he deserves. Brain development does not grow with your child age itself. Actually, it depends on experience and practice that your child captured from the outer world. Sight, touch, taste and smell helps to produce brain cells. These are known as cineplex. These four sense constructs billions new cells.  These cells make connections with brain tissues and as a result, it increases brain capabilities.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\"><strong>2 . Let feel them new experience:</strong> whenever let you know them different experiences than it helps to foster their developing stages. Similarly when you love your child and feel them secured than it increases brain cells connection. Your child development is a continuous process it never stops. When we use children's capabilities than their brain starts developing itself. When we do not use their capabilities and intelligence than brain development become slow.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\"><strong>3. More effect in younger age:</strong> the first stage time of your children is the base of his whole life. Whatever conditions your children faced during their childhood, this time or experience make them that kind of human. How he Behaves in school, how he feels their relation with others. All these depends on their childhood also. by this way, you can work on your child development.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\"><strong>Use these tips to make their mind sharp:</strong></div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\">1. According to Research if you're going to tell them orally than it definitely helps to recognize their capabilities. It should be done from born stage to three years.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\">2. Always try to appreciate your child whenever they are trying to do something. Keep in mind if you are appreciated them too much then they move to easy task and move away from the different and difficult task. It is necessary that your child challenges himself ,it is necessary that he faced failure also time to time because it means his target is still away from them.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\">3. Attend their school activities and PTM  also.  It shows that you are taking their responsibilities with full concentration.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\">4.  To succeed in life discipline and willing power are more important than eye Que.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\">5. Without kindness and morality, their intelligence can ruin them.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\">6. Select toys for your child ,which increase their creativity.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\">7.If your child learns music and musical instruments than it is also a good option to develop their mind.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\">8. <a href=\"http://www.mytrendin.com/best-university-in-the-world-today/\" title=\"Mathematics\" alt=\"Mathematics\">Mathematics</a> is very important for child development so <a href=\"http://www.mytrendin.com/best-university-in-the-world-today/\" title=\"tell then\" alt=\"tell then\">tell then</a> it is an easy subject. Try</div>\n<div dir=\"auto\">to teach then this subject by giving real examples of daily life.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\">9. Let them enjoy their childhood <a href=\"http://www.mytrendin.com/best-university-in-the-world-today/\" title=\"otherwise\" alt=\"otherwise\">otherwise</a> <a href=\"http://www.mytrendin.com/best-university-in-the-world-today/\" title=\"they\" alt=\"they\">they</a> would feel stressed.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\">10.  If you are taking any kind of decision then tell your children in deep, just do not order them. Let him continue his words.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\">11. Teach your child more than one language because it increases their grasping power.</div>\n<div dir=\"auto\"></div>\n<div dir=\"auto\">12 .  If you give permission to your children to use your smartphone or Tablets than motivate them to use educational applications.</div>\n<div dir=\"auto\"> These points will definitely help you to grow your child development. Motivation should be present in your parenting style.</div>\n",
  "protected": false
},
"excerpt": {
  "rendered": "<p>Child development | How fast your child will be, it depends on you too much. What methods are you going to apply on them? This is overall your duty. A child spends his time at home as compared to school two times faster. Most children spend their time to watch TV and playing games on [&hellip;]</p>\n",
  "protected": false
},
"author": 1,
"featured_media": 481,
"comment_status": "open",
"ping_status": "open",
"sticky": false,
"template": "",
"format": "standard",
"meta": [],
"categories": [
  64
],
"tags": [
  132,
  133
],
"_links": {
  "self": [
    {
      "href": "http://www.mytrendin.com/wp-json/wp/v2/posts/479"
    }
  ],
  "collection": [
    {
      "href": "http://www.mytrendin.com/wp-json/wp/v2/posts"
    }
  ],
  "about": [
    {
      "href": "http://www.mytrendin.com/wp-json/wp/v2/types/post"
    }
  ],
  "author": [
    {
      "embeddable": true,
      "href": "http://www.mytrendin.com/wp-json/wp/v2/users/1"
    }
  ],
  "replies": [
    {
      "embeddable": true,
      "href": "http://www.mytrendin.com/wp-json/wp/v2/comments?post=479"
    }
  ],
  "version-history": [
    {
      "href": "http://www.mytrendin.com/wp-json/wp/v2/posts/479/revisions"
    }
  ],
  "wp:featuredmedia": [
    {
      "embeddable": true,
      "href": "http://www.mytrendin.com/wp-json/wp/v2/media/481"
    }
  ],
  "wp:attachment": [
    {
      "href": "http://www.mytrendin.com/wp-json/wp/v2/media?parent=479"
    }
  ],
  "wp:term": [
    {
      "taxonomy": "category",
      "embeddable": true,
      "href": "http://www.mytrendin.com/wp-json/wp/v2/categories?post=479"
    },
    {
      "taxonomy": "post_tag",
      "embeddable": true,
      "href": "http://www.mytrendin.com/wp-json/wp/v2/tags?post=479"
    }
  ],
  "curies": [
    {
      "name": "wp",
      "href": "https://api.w.org/{rel}",
      "templated": true
    }
  ]
}
  }
   ]