Proper way to create custom static page

As has been mentioned, your way works, but there are some ways you can decouple the form from the template, allowing more flexibility. The Shortcode API allows you to create a shortcode for your form, so you can simply enter something like [my_form] in the page’s content, then within the function that handles your shortcode … Read more

Loop and add Specific Categories and Products Images

In your functions.php function show_all_thumbs() { global $post; $post = get_post($post); $images =& get_children( ‘post_type=attachment&post_mime_type=image&output=ARRAY_N&orderby=menu_order&order=ASC&post_parent=”.$post->post_parent); if($images) { foreach( $images as $imageID => $imagePost ){ unset($the_b_img); $the_b_img = wp_get_attachment_image($imageID, “thumbnail’, false); $thumblist .= ‘<a href=”‘.get_attachment_link($imageID).'”>’.$the_b_img.'</a>’; } } return $thumblist; } In your page template file: $loop = new WP_Query( array( ‘post_type’ => ‘demo’, // or whatever … Read more

The $post variable – Did I get the grasp of how the Backend actions get parsed?

As I’ve already wrote in question comments, at the very beginning of creating the new post or page first choose a template and save as draft. Meta box will appear after save if right template is used. <?php add_action( ‘add_meta_boxes’, ‘my_add_meta_box’ ); function my_add_meta_box() { // get template file name $template_basename = wp_basename( get_page_template() ); … Read more

Find out in which kind of archive am I

Inspect get_queried_object(). On an archive for the category Uncategorized you get something like … stdClass Object ( [term_id] => 1 [name] => Uncategorized [slug] => uncategorized [term_group] => 0 [term_taxonomy_id] => 1 [taxonomy] => category Find out in which kind of archive am I => [parent] => 0 [count] => 8 [cat_ID] => 1 [category_count] … Read more

Outputting content from page

wp_get_attachment_image_src returns an array, not a single value. Please refer to this article for more info: wordpress.org/Function_Reference/wp_get_attachment_image_src Default Usage <?php $attachment_id = 8; // attachment ID $image_attributes = wp_get_attachment_image_src( $attachment_id ); // returns an array ?> <img src=”https://wordpress.stackexchange.com/questions/87552/<?php echo $image_attributes[0]; ?>” width=”<?php echo $image_attributes[1]; ?>” height=”<?php echo $image_attributes[2]; ?>”>

How to bypass 404 for certain pages/posts?

When you add a custom post type, WordPress doesn’t know that it needs to regenerate it’s permalinks/rewrite rules. Visit the permalinks settings page to flush and regenerate the links and your custom post type permalinks will start to work, else you’ll get 404 messages. A word of warning: Some people will advise you call flush_rewrite_rules … Read more

How to differentiate the homepage structure from the category page structure in WordPress template?

If I understand you… Your theme may only have an index.php and a single.php but WordPress supports a much more complicated templating system, and you can control the formatting of different types of content just by creating files with the right names. In your case, I think that at least one of the files you … Read more