Wordpress Flashcards
What PHP function can be called to get the name of the blog (for templating)?
bloginfo(‘name’);
What PHP function can be called to get the name of the stylesheet?
bloginfo(‘stylesheet_url’);
What function is used to include the header of a theme file?
get_header()
What function is used to include the footer of a theme file?
get_footer()
What function is called just before the end of the head block of a theme to allow wordpress to ‘hook’ into the head?
wp_head()
What function is called just before the end of the body tag, so that wordpress can provide hooks for plugins?
wp_footer()
What function is used to get the template directory?
i.e. in templates, you may need to specify the root folder the images and content lives in
echo get_template_directory_uri();
How do you setup a query for posts?
query_posts(‘posts_per_page’);
How do you iterate through the posts from a query?
while(have_posts()) {
the_post();
the_permalink();
}
How do you get the heading of a post?
the_post();
How do you get the link to a post?
the_permalink();
Once you’ve made your query using query_posts - what should you do to clean up?
wp_reset_query()
Should a theme use query_posts?
No - it may fail, and is inefficient. I would use pre_get_posts action.
What function do you call to get the content of a post?
the_content();
This is normally done in a page called single.php
How do we get the thumbnail for the post?
the_post_thumbnail(array(300, 300));
How can we determine if a page is the front page?
You can use the function
is_front_page();
What method gives you the title?
the_title();
What method gives you the permalink?
the_permalink()
Why is it we can see a 980px layout on a 320px size iPhone screen?
There is the notion of viewports and screen sizes. The viewport is 980px, and the screen size is 320px. The web page is first loaded into the viewport then resized to the screen size.
What is the following meta-tag doing?
meta name=”viewport” content=”width=device-width”
It is telling the device to match the viewport width with the device width. Using the meta tag is probably the best supported method, and easier than specifying viewport sizes on a per device basis.
The initial-scale part of the meta tag does what?
It controls the amount of zoom applied to the webpage - note, it is just the initial zoom, the user can change it.
Because some older browsers do not know how to deal with media queries, what library can we use to fix this?
respond.js
Whats the difference between
@media and (max-width:632px)
and
@media screen and (max-width:632px)
Not a lot - it’s very similar - however, the use of the term screen specifies we are only targetting screen media types, and not other types such ‘print’.
Whats the difference between
@media screen and (max-width:632px)
@media only screen and (max-width:632px)
Basically the ‘only’ keyword hides the media query from older browsers. According to the W3C, the user-agent must process the only keyword as if it isn’t present, but older browsers don’t recognise it, so they ignore it.