Pages

.

Showing posts with label Guide. Show all posts
Showing posts with label Guide. Show all posts

A How To Guide To Call Pages Within Menus Dynamically

Do you own a page-based WordPress website? Are you fed up with calling pages within menus? If your answer to both these questions is a "Yes" then this tutorial is for you. Here, I've used an example for explaining the process of calling pages within menus dynamically.

Is calling pages dynamically from back-end all that tedious?

No, not at all! You're not required to get into the hassles of writing any lengthy code for calling web pages(for eg: About Us, Contact Us etc.) dynamically from the WordPress back-end. Just the mere addition of a simple code snippet will do the job.

Understanding the process of calling pages within menus dynamically, using an example

WordPress comes with an in-built function "wp_list_pages($args)" for displaying the list of pages and their sub-pages. This function has an array type parameter which is used for managing the structure of pages along with their listing. Here's a look at the different parameters available for $args:

$args = array(

'authors' => '',

'child_of' => 0,

'date_format' => get_option('date_format'),

'depth' => 0,

'echo' => 1,

'exclude' => '',

'include' => '',

'link_after' => '',

'link_before' => '',

'post_type' => 'page',

'post_status' => 'publish',

'show_date' => '',

'sort_column' => 'menu_order, post_title',

'sort_order' => '',

'title_li' => __('Pages'),

'walker' => ''

);

Below is an elaboration of all the function arguments one by one:

1. authors:

argument type==>(string)

With this argument, you can include only the pages which have been authored by authors in a comma-separated list of author IDs. However, if no authors have been specified, all authors are included by default.

2. child_of:

argument type==>(integer)

This argument displays the sub-pages of a single page. It uses the ID for a page as a value. Here, you need to note that the child_of parameter will fetch "grandchildren" of the given page ID and not just the immediate children. The default value for this argument is 0, which means all pages are displayed.

3. date_format:

argument type ==> (string)

This argument controls the format of Page date set by show_date parameter(the value for this parameter can be l, F J, Y), which further defaults to the date format that has been configured in the WordPress settings options.

4. depth:

argument type==>(integer)

By using the above parameter, you can control the count for levels in the hierarchy of pages that need to go into the list generated by wp_list_pages. Different values for this parameter mean different things. Have a look at these:

0- This is the default value which means all the pages and their sub-pages will be displayed at any depth and arranged hierarchically using nested lists.

-1- This means all pages will be displayed at any depth and arranged in a single, flat list

1- This means only the top-level pages will be displayed

2, 3....- This means pages will be displayed at a given depth.

5. echo

argument type==?(boolean)

Using this argument toggles the display of generated list of links or returns the page list as an HTML text string to be used in PHP. Here the values that can be assigned to this argument:

1(True)- this is the default value and displays the generated list items

0(False)

6. short_order

argument type==> (string)

This argument changes the sort order of the list of pages in an ascending or descending order. Valid values for this argument include:

'ASC'- This sorts the page list from lowest to highest. It is the default value for this argument.

'DESC'- This sorts the page list from highest to lowest

7. exclude

argument type ==> (string)

This argument defines a comma-separated list of page IDs that need to be excluded from the page list. For example, exclude= 2, 5, 21 and son on). There is no default value for this argument.

8. exclude_tree

argument type ==> (string)

This argument defines a comma-separated list of parent page ID;s that need to be excluded from the page list. You can use this argument for excluding a parent page id and all child pages for the respective parent page. For example, 'exclude_tree=6' will exclude the parent page 6 along with its child pages.

9. link_before:

argument type ==> (string)

Use this argument for setting the text or HTML which precedes the link text available inside the tag.

10. link_after:

argument type ==> (string)

Use this argument for setting the text or html that follows the link text available inside the tag.

11. sort_column:

argument type ==> (string)

This argument will sort the list of pages in multiple ways with the default setting being sorted alphabetically using Page title. Here is a look at some of the values for you to choose from, for this argument:

'post_title' - Use this value for sorting Pages alphabetically (by title). This is the default value displayed for the argument.

'menu_order' - Use this value to sort Pages by Page Order. Here, make a note of key difference between Page Order and Page ID. The Page ID is a unique number assigned by WordPress to every post or page.

'post_date' - Use this value to sort pages by their creation time.

'post_modified'- Use this value for sorting pages by time last modified.

'ID' - Use this value for sorting pages by numeric Page ID.

'post_author' - Use this value for sorting pages by the Page author's numeric ID.

'post_name' - Use this value for sorting pages alphabetically by Post slug.

12. sort_order:

argument type ==> (string)

This argument will change the sort order of the list of pages in an ascending or descending order. Valid values for this argument include:

'ASC'- Use this value for sorting the pages from lowest to highest.

'DESC'- Use this value for sorting pages from highest to lowest.

13. Walker:

Walker is an abstract class which simply "walks" through each node within a tree(for eg: an object or associative array) and executes an abstract function at each node. As a developer, you need to define abstract methods within the custom child class for taking an action at each of the nodes.

14. post_type :

argument type ==> (string)

This argument will list all posts associated with a certain hierarchical Post Type. Valid values for this argument include:

'page'

'revision'

Hierarchical Custom Post Types

15 ) post_status :

argument type ==> (string)

This argument will display a comma-separated list of post status types to return. Valid values for this argument include: 'publish, private, draft'.

Now, in order to show the pages and their sub-pages, just use the below code snippet:

That's it!

Summing Up

Hopefully all the pointers covered above would definitely help out in calling pages dynamically via your WordPress admin panel. Do drop in your feedback and/or suggestions regarding the post.

Ben Wilson is expert WP Developer for WordPrax Ltd & expert in converting HTML to WordPress theme. He also provides concrete information on front end development and WordPress development. If you have any concern or question related to Wordpress, you can get in touch with him.
reade more... Résuméabuiyad

A Guide to Weight Loss Surgery & Bariatric Surgery

Bariatric surgery is often called as weight loss surgery, one of the amazing blessings of medical science for those people who have concerns about your weight. Several people are out there struggling with their weight that reached a stage where they are no longer comfortable with it. Increased body weight makes your movement difficult and keeps you away from several activities that you were easily performed, plus added lots of problems that were out of your reach of concerned about before.

Probably it's not like that you have not attempted to lose your weight before it deteriorates. Numerous individuals perform exercising with the combination of eating plan that they thought is the best for shedding pounds however yet there is no positive result. For these individuals, medicinal science provides a decent opportunity to lose their undesirable weight through surgery, known as bariatric or weight reduction surgery.

Weight loss surgery often restraint the amount of food taken in furthermore influences the way you absorb nutrients and digest food. BS is a part of gastrointestinal surgery that alters the digestive process to achieve weight loss quickly. The entire surgery can be performed in any one of two ways that includes Gastric Banding and Gastric Bypass.

In GBS, using laparoscopic technique, a band is fitted on the top of the patient's stomach. Just a little amount of food needs to be expended, after which the patient would as of now feel full. Having the surgery performed on your stomach implies that you need to consume your food quite slowly, to process it better. This surgery leads to loss of about 40% of excess weight and is considered as the safest one to reduce the excessive body weight.

GBS is of three types such as Adjustable Gastric Banding, Vertical Sleeve Gastrectomy, and Vertical Banded Gastroplasty. Collectively they are known as restrictive weight loss surgeries. These surgeries are safer and easier to perform because of laparoscopic technique used in the procedures. However some risks are also involved in the surgery such as vomiting, slippage of the band and rarely the breaks in the tubing.

On the other hand, in Gastric Bypass surgery, a more modest stomach is made and through this bypass the patient would have a feeling of already being full, despite the fact that he has just consumed a generally little amount of food. Also on the grounds that the patient is feeling full at an early timing, it implies that he would be eating lesser calories than if he would be consuming consistently. It is most common weight loss surgery practiced around the world because of fewer complications and risks involvement as compared to other bariatric surgery.

This surgery provides several benefits such as it greatly controls the intake of food, dumping syndrome and in case of emergency, it is possible to reverse this surgery.

Dr Pradeep Jain is Highly experienced and knowledgeable GI surgeon, Dr Pradeep Jain Fortis works through tiny incisions to perform several laparoscopic procedures of Gastrointestinal tract.
reade more... Résuméabuiyad