How to force load a page in plugin?
If /foo doesn’t exist as a page, you can map the URI to another page with a rewrite rule: function wpa_rewrite(){ add_rewrite_rule( ‘foo/?$’, ‘index.php?page_id=3’, ‘top’ ); } add_action( ‘init’, ‘wpa_rewrite’ );
If /foo doesn’t exist as a page, you can map the URI to another page with a rewrite rule: function wpa_rewrite(){ add_rewrite_rule( ‘foo/?$’, ‘index.php?page_id=3’, ‘top’ ); } add_action( ‘init’, ‘wpa_rewrite’ );
If you want to use custom page templates, yo have to: Create file for your template. On beginning of your file add comment defining that this file is custom template file (/* Template Name: One column, no sidebar */). Manually set that chosen page should use this custom template. Of course you can also create … Read more
By default, there is no feed for pages. So Feedburner doesn’t know if or when a page was created or updated. If you didn’t set up a custom feed for pages Feedburner will not get this information.
function add_js_one_col_wpse_107240() { if (is_page()) { $pobj = get_queried_object(); if(!empty(get_post_meta($pobj->ID,’one-col’,true)) { wp_enqueue_script(/* … */); } else { wp_enqueue_script(/* … a different script … */); } } } add_action(‘wp_enqueue_scripts’,’add_js_one_col_wpse_107240′); get_queried_object will get you the page information. It will be a WP_Post object on a “Page”. global $post should probably work too, but this is cleaner. Use … Read more
Removing the first “wp_reset_postdata ();” solved the problem.
You can do this but before I tell you how I have to express a concern. You will have severe duplicate content problems if all of your pages are the same except for that <h2> tag. Now, what you need to do is create a Custom Page Template, with the following: <?php /* Template Name: … Read more
Check how many ancestors the page has via get_post_ancestors: // grandchild pages will have two or more ancestors if( 2 <= count( get_post_ancestors( $post->ID ) ) ){ echo ‘grandchild page’; }
as the 5 parameter to add_menu_page() you send the resultat of running the function, insted of sending a callable reference to the function, as you did in the add_action. $hookname = add_menu_page ( ‘My Slider’, ‘My Slider’, ‘manage_options’, ‘my_slider’, array( ‘My_Slider’, ‘render_admin_menu’) );
You can use get_nav_menu_locations and wp_get_nav_menu_items to get your menu items. $locations = get_nav_menu_locations(); $nav_items = wp_get_nav_menu_items($locations[‘your-menu-slug’]); You can then process $nav_items to display your page content. It can get complicated but it does work.
What about using the UNION? Just an example: (SELECT * FROM $wpdb->posts (with JOIN and WHERE as needed)) UNION (SELECT * FROM $wpdb->posts (with WHERE to select pages)) GROUP BY/ORDER BY The select(s) must be in parenthesis to use an order by for the whole union result. As a second option, you can use a … Read more