How to change the permalink structure of a master page?

To remove pagination prefix page in home page you should: add a rewrite rule which will translate the new link format, prevent redirection to address containing page, replace URLs in paging links. By creating pagination links, WordPress appends query var paged with mentioned prefix to url. Therefore, without modification, the links would look like example.com/3/page/3. … Read more

add_rewrite_rule with bottom priority doesn’t handle the WordPress pages

When you point a rule to anything other than index.php, it gets interpreted as external and written to the .htaccess file. After external rules are parsed, requests get directed to WordPress, which parses the internal rules in php. This is the internal version: function custom_rewrite() { add_rewrite_rule( ‘^(bar|baz|foo-.*)’, ‘index.php?my_var=$matches[1]’, ‘top’ ); } add_action( ‘init’, ‘custom_rewrite’ … Read more

Show different badge based upon the user role

You can use get_queried_object to get data in the current author page: <?php $author = get_queried_object(); // uncomment next line to see all author data // print_r( $author ); if( in_array( ‘author’, $author->roles ) ) : echo “author”; elseif( in_array( ‘subscriber’, $author->roles ) ) : echo “subscriber”; endif;

Calling a function from functions.php in custom page/ blog post

You could use add_shortcode if you want to use it within the editor. function footag_func() { return “Test”; } add_shortcode( ‘footag’, ‘footag_func’ ); And then use [footag] in your editor. Or Use code like this in functions.php and add a conditional tag add_action( ‘loop_start’, ‘your_function’ ); function your_function() { if ( is_singular(‘post’) ) { echo … Read more

Multiple loops in same page, without duplicate content

it is important to read this Codex chapter all the way to the end, as the essential suggestions are after this heading ‘Note for Multiple Posts in the First Category’; repetitive, tedious code: <?php $do_not_duplicate = array(); ?> <?php $mosaics = new WP_Query(‘category_name=mosaics&posts_per_page=5’); ?> <?php while ($mosaics->have_posts()) : $mosaics->the_post(); ?> <?php $do_not_duplicate[] = $post->ID; ?> … Read more

eBooks download website, page or post?

Pages are relatively more static. They don’t change much. Posts on the other hand do change on a regular basis. Just like any store, it’s best to use posts in this case. You can also create a custom post type and call it “ebooks”. It would be more appropriate, but posts can do fine.

Wrong Sub-Page Order

Try this: $args = array( ‘sort_order’ => ‘asc’, ‘sort_column’ => ‘menu_order’, ‘hierarchical’ => 1, ‘parent’ => $post->ID ); $pages = get_pages($args);