Create a page without adding a page in the Database

To wit, this technically isn’t a ‘page’, however it’s a way to surface content using mod_rewrite. The goal here is to add a URI segment of foobar that will trigger a custom query, then include the specified template file. Add a rewrite rule: add_action(‘init’, ‘foo_add_rewrite_rule’); function foo_add_rewrite_rule(){ add_rewrite_rule(‘^foobar?’,’index.php?is_foobar_page=1&post_type=custom_post_type’,’top’); //Customize this query string – keep is_foobar_page=1 … Read more

Access the same page from multiple urls (wildcard)

You can use template_include, but before you hook to this filter you must do the following steps: Create page template. e.g: page-target.php <?php /** * Template Name: Page Target */ … Manually query the contents of target-page on page-target.php template, because the global $post will be referencing to your some-prefix-* page. (Optional): Edit and apply … Read more

Proper way to get page content

Just to clarify: You mixed two things here. qTranslate stores the different languages in the same post. If you call get_content(), $post->content or an other direct query, you will get the whole content with all different languages from the database. What qTranslates do, it creates a filter-hook which is attached to the_content hook. If somebody … Read more

Listing pages which uses specific template [duplicate]

You can do this with a WP_Query meta_query. The page template filename is stored in post meta under the key _wp_page_template: $args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => -1, ‘meta_query’ => array( array( ‘key’ => ‘_wp_page_template’, ‘value’ => ‘product.php’ ) ) ); $the_pages = new WP_Query( $args ); if( $the_pages->have_posts() ){ while( $the_pages->have_posts() ){ … Read more

Check IF is a “single product page” and Check the “role” for a Redirect

Here is the result that works, I put in the condition : is_product() to check if is a single product page. And I changed in the add_action() : admin_init by wp function cm_redirect_users_by_role() { $current_user = wp_get_current_user(); $role_name = $current_user->roles[0]; if ( is_product() ){ if ( $role_name !== ‘customer’ && $role_name !== ‘shop_manager’ && $role_name … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)