List all anchor links on a page

In short, you’ll run the loop twice. The first time creating the links. The second time creating the posts. The trick is to figure out what the ID will be for the post. It needs to be something unique: We could use the slug or the post ID. <?php // I’m going to get the … Read more

on page creation few inline style properties gets removed

Thought the language is a bit confusing, if you check the Codex and pay attention to the difference between the Admin and the Super Admin you should be able to see what is happening. In the case of single site WordPress installation, Administrators are, in effect, Super Admins. As such, they are the only ones … Read more

Use page template for custom $_GET content

You can use the template_include filter to load a template file from your theme: add_filter( ‘template_include’, ‘my_page_template’, 99 ); function my_page_template( $template ) { if ( isset( $_GET[‘info’] ) && $_GET[‘info’] == ‘some_value’ ) { $new_template = locate_template( array(‘my-template.php’ ) ); if ( ” != $new_template ) { return $new_template ; } } return $template; … Read more

Showing recent post of category in page

Here is a start. This is how I display related posts from the category the post are in. You will just need to add your own loop and CSS Create a template called content-related.php Inside that paste the following code <?php /** * The default template for displaying realted posts * * @package WordPress * … Read more

is_single(); Question

You should have a look at using conditional tags in wordpress. is_single() is the conditional tag for a single page, ie single.php. For homepage, is_home() or is_front_page() should be use, depending on whether a front page is set in settings or not.

How to get main menu only with wp_nav_menu

You can use the depth parameter like this: wp_nav_menu( array( ‘menu’ => ‘header-uk’, ‘menu_id’ => ‘nav’, ‘menu_class’ => ‘sitemap’, ‘fallback_cb’ => false, ‘depth’ => 1, ) ); Or if what you want to do is grab all items to create your own loop/output you can do that as well. Example: if ( ( $locations = … Read more

How to get current page nearest parent id?

try this. global $post; // if outside the loop $page_object = get_queried_object(); $page_id = get_queried_object_id(); // Get current page id $args = array( ‘sort_order’ => ‘ASC’, ‘sort_column’ => ‘post_title’, ‘hierarchical’ => 1, ‘exclude’ => ”, ‘include’ => $page_id, ‘meta_key’ => ”, ‘meta_value’ => ”, ‘authors’ => ”, ‘child_of’ => 0, ‘parent’ => -1, ‘exclude_tree’ => … Read more