optional parameter in permalink structure

Update You can make use of the add_rewrite_endpoint: add_rewrite_endpoint( ‘schools’, EP_PERMALINK | EP_PAGES ); You can then check in the sidebar for the schools variable: global $wp_query; if ( isset( $wp_query->query_vars[‘schools’] ) ) { // … } What is worth mentioning is that your URL will look like www.example.com/performance/name-of-performance/schools/ instead of having schools immediately after … Read more

I want to filter my products with attributes [closed]

As per what I understood from your question, you want two things – Listing of all publisher Listing of all books of a particular publisher. Here is code for both. Listing of all publisher $terms = get_terms( ‘pa_publisher’ ); echo ‘<ul>’; foreach ($terms as $each_term) { echo ‘<li>’.$each_term->name.'</li>’; } echo ‘</ul>’; Listing of all books … Read more

Permalinks – .htaccess

According to the official WordPress docs, when you save your Permalinks it updates your .htaccess file … This isn’t correct. When you switch from default– ?= permalinks which are nothing but pure PHP URL parameter passing– to anything else then WordPress will create a .htaccess file if it can, or tell you to create one. … Read more

Pagination of custom post type leads to 404 error

Paste this function to your functions.php file if ( ! function_exists( ‘custom_pagination’ ) ) { function custom_pagination( $query_args ) { $big = 999999999; // need an unlikely integer $pages = paginate_links( array( ‘base’ => str_replace( $big, ‘%#%’, esc_url( get_pagenum_link( $big ) ) ), ‘format’ => ‘?paged=%#%’, ‘current’ => max( 1, get_query_var( ‘paged’ ) ), ‘total’ … Read more

Custom Post Types,Permalink and Heirarchy

My problem was solved with this link. It was very helpful and difficult to find. function add_custom_query_var( $vars ){ $vars[] = “brand_name”; return $vars; } add_filter( ‘query_vars’, ‘add_custom_query_var’ ); function add_rewrite_rules($aRules) { $aNewRules = array(‘brand/([^/]+)/?$’ => ‘index.php?pagename=hotel&brand_name=$matches[1]’); $aRules = $aNewRules + $aRules; return $aRules; } add_filter(‘rewrite_rules_array’, ‘add_rewrite_rules’);

How to remove the link of an image on WP 4.2

The option for setting the url to none using “Attachment Display Settings” is available through the gallery option, using “Add Media”. How are you adding your images—through featured image or directly in your post/page? You can remove the my image if it’s in the post itself. For featured images, you’ll have to go into your … Read more