Logo F2FInterview

Wordpress Interview Questions

Q   |   QA

Any Category with a non-zero value for # of Posts in the Administration > Manage > Categories cannot be deleted. The uncategorized Category might be assigned to some Posts, but all Pages are assigned the uncategorized Category. So even though there may be no posts assigned to the uncategorized Category, Pages are included in the count of # of Posts.

The default category cannot be deleted even if it is empty, however you can specify your default categories for posts or links on the Options - Writing page of the admin panel. 

If there is no Page Template option when writing or editing a Page it may because there is no template file with the proper structure. For the Page Template box to be available to assign to a Page there must be a least one template file in your theme that has a structure at the beginning of the template file that looks like this:

<?php
/*
Template Name: Links
*/
?>

That example is from the WordPress Default themes wp-content/themes/default/links.php file, so replace Links with your desired template name.

Note: Sometimes it is necessary to switch to the WordPress Default Theme, then back to your theme, for the Template choices to appear!

If using WordPress as a CMS, you might want to present readers with a static front page, and then display your posts on another page called Blog. To accomplish that follow these instructions:

  •         Create a Page and use "My Front Page" for the Page Title. Of course, in the content for that Page, you can enter the information you want presented on your site's front page (see example below if you want to display a post).
  •         Create a Page and call it Blog. Nothing needs to be entered in the content field of this Page.
  •         In Administration > Settings > Reading set the Front page displays to A static page, and select My Front Page for Front page:, and select Blog for the Posts page:.

If you want to further customize your front page, you can create a Template, and fit it to meet your needs:

  • With the help of the Template Hierarchy article, determine what Template is normally used to display your Pages (e.g. page.php or index.php).
  • Copy that template to myfront.php. If you were using the WordPress Default theme you would copy wp-content/themes/default/page.php to wp-content/themes/default/myfront.php.
  • In Administration > Appearance > Editor, edit the myfront.php and change the beginning of the file from:

<?php
/**
* @package WordPress
* @subpackage Default_Theme
*/

to:

<?php
/*
Template Name: MyFront
*/
?>

  • Then access the Page called Front in Administration > Page > Edit and set the Template to MyFront.
  • Once that's all working, begin changing myfront.php to make it look like what you want.
  • That's it. You are done.


Use this example for the 'MyFront' Page Template if you want to display one post, instead of the Page content, on your 'static front page':

<?php
/*
Template Name: MyFront
*/
?>

<?php get_header(); ?>

<div id="content" class="narrowcolumn">

<?php

query_posts('p=1'); //set p=x where x is post id of post you want to see or use query_posts('cat=1&posts_per_page=1); to show one post from Category 1
if (have_posts()) : ?>

<?php while (have_posts()) : the_post(); ?>

<div <?php post_class() ?> id="post-<?php the_ID(); ?>">
<h2><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></h2>
<small><?php the_time('F jS, Y') ?> <!-- by <?php the_author() ?> --></small>

<div class="entry">

<?php the_content('Read the rest of this entry »'); ?>
</div>

<p class="postmetadata"><?php the_tags('Tags: ', ', ', '<br />'); ?> Posted in <?php the_category(', ') ?> | <?php edit_post_link('Edit', '', ' | '); ?> <?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?></p>
</div>

<?php endwhile; ?>

<div class="navigation">
<div class="alignleft"><?php next_posts_link('« Older Entries') ?></div>
<div class="alignright"><?php previous_posts_link('Newer Entries »') ?></div>
</div>

<?php else : ?>

<h2 class="center">Not Found</h2>
<p class="center">Sorry, but you are looking for something that isn't here.</p>
<?php get_search_form(); ?>

<?php endif; ?>

</div>

<?php get_sidebar(); ?>

<?php get_footer(); ?>
 

Sometimes it is necessary to know the ID of a particular Post, Page, Category, Tag, Link, Link Category, or User. To determine that ID, use one of these method:

  • Look in your browser status bar for the ID:
  1. Visit the related 'Edit' screen in your Administration Panel. For instance in the case of Posts visit Posts->Edit, for Pages visit Pages->Edit, and for Categories visit Posts->Categories.
  2. Now hover your mouse over the 'item' you need the ID. In the case of Pages, hover over that particular Page's title in the Title column and for Categories hover over the Categories Name in the Name column.
  3. Look at the status bar (at the bottom of your browser) and the you will find at the end of the line something like "post=123" or "cat_ID=67". In these cases, 123 is the Page ID, and 67 is the Category ID.
  • Install a plugin:
  1. Install and activate Reveal IDs for WP Admin, Simply Show IDs, or ShowID for Post/Page/Category/Tag/Comment.
  2. Find the ID displayed with each item.

To configure the way the post's categories display, open the index.php file and find the line <div class meta>. There you will see the following code:

<?php the_category() ?>

Inside of the parentheses ( ) and quote marks, add or change this to reflect the new look you desire.

If you would like to have commas between the categories, the tag should read:

<?php the_category(',') ?>

If you would like to have an arrow, the tag would look like this:

<?php the_category(' > ') ?>

If you would like to have a bullet, the tag would look like this:

<?php the_category(' &bull; ') ?>

If you would like the "pipe" ( | ) between the categories, the tag would look like this:

<?php the_category(' | ') ?>

Use your imagination and creativity to make the separations in the categories look any way you like. 

In order to link this F2FInterview's page as Reference on your website or Blog, click on below text area and pres (CTRL-C) to copy the code in clipboard or right click then copy the following lines after that paste into your website or Blog.

Get Reference Link To This Page: (copy below code by (CTRL-C) and paste into your website or Blog)
HTML Rendering of above code: