Tag Info

Hot answers tagged

3

Yes, this is the intended behaviour: page-{slug}.php - If the page slug is recent-news, WordPress will look to use page-recent-news.php So, simply use a different filename for your templates, like template-contact.php for example. You can find more info about this here: https://codex.wordpress.org/Template_Hierarchy


3

wp_list_pages will output all of the pages, posts, and CPTs that you wish. You even have control over the CSS classes, some of which are already there: All list items (li) generated by wp_list_pages() are marked with the class page_item. When wp_list_pages() is called while displaying a Page, the list item for that Page is given the additional class ...


2

I guess what you're looking for is an author template. You can create an author.php in your template folder and arrange the information in there like you want to. It will be a general template for every user then. You can access the author page if you visit example.com/author/author-slug/ To give an example: http://bookish.brokenstars.de/author/fyn/ I'm ...


2

If I understand well your want to show the widgets adding and removing interface inside a meta box. An easy, -a little dirty- way is using an iframe: function metaboxed_widgets_admin() { if ( ! current_user_can( 'edit_theme_options' ) ) return; add_meta_box('metaboxed_widgets', __('Widgets'), 'metaboxed_widgets_admin_cb', 'page'); } add_action( ...


2

Parsing shortcodes from strings WordPress parses and replaces shortcodes from a piece of content via the do_shortcode function. This function, in turn, calls get_shortcode_regex, which returns the regular expression for matching shortcodes in a string. Using this function, we can get a list of all shortcodes ourselves: $pattern = get_shortcode_regex(); ...


2

I'm not sure why you use the sort_column parameter, it's not supported by the WP_Query() class. According to the Codex, the correct way to sort, is to use the order and orderby parameters. Please try this: $args = array( 'post_type' => 'page', 'orderby' => 'menu_order', 'order' => 'ASC', // ...


1

Yes it is, and this can be a very handy feature. The 'hiding place' for widgets is one of the least intuitive designs of the Wordpress backend, IMHO. You can use a plugin such as: Widgets on Pages Or perhaps a more up-to-date one such as Widgetize Pages Or you can build code yourself and place it elsewhere in the admin (such as the dashboard). A tutorial ...


1

You can try to use functions.php to handle the form submission and send the data via AJAX. Add a hidden field in your form with the action to be taken (on functions.php): <input type="hidden" name="action" value="save_contact"/> In you footer.php add the jQuery code to handle the AJAX request: jQuery('#your-form').submit(ajaxSubmit); function ...


1

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 plugin to enable the categories and ...


1

Not a specific answer, but will be too long for a comment. You could also try looking at the code that WordPress core uses itself. I know you said you couldn't use the check box that auto-adds pages, but you could look over how it is being used. A little digging around (with a decent text editor you should be able to search for a phrase throughout the entire ...


1

You have to either 1) take all the whitespace out of the scripts and iframes so WordPress does not add <p> tags and then the JS and iframe links will work, or 2) disable autop in the post editor for all posts/pages (see http://codex.wordpress.org/Function_Reference/wpautop ) so WP doesn't add paragraph breaks, or 3) do the following, which leaves ...


1

The post count uses the wp_count_posts() function, which ignores any query filters. You'll need to tweak it manually with the use of the wp_count_posts filter: function wpse_139851_count_posts( $counts, $type ) { if ( $type === 'page' && ! empty( $counts->publish ) ) $counts->publish--; // Decrease by 1 return $counts; } ...


1

Yes, the count for pages in various statuses that you see above the list table is obtained running wp_count_posts but the pages in the table are obtained running a WP_Query and the 2 things are completely unrelated. If you want to also modify the count, you have to filter also the output of wp_count_posts using the 'wp_count_posts' filter hook. Also you ...


1

There are no page folders in WordPress, though that's a good idea. Create subpages; that will give you a visual hierarchy, an also an automatic "breadcrumb" hierarchy, if useful. But you will still be able to organize pages in menus any way you want. See https://codex.wordpress.org/Pages And/or use CMS Page Tree View ...


1

Well, yes, of course. Take a look at this reference: http://codex.wordpress.org/Function_Reference/previous_post_link http://codex.wordpress.org/Function_Reference/next_post_link You can customize it however you like, so you can simply put an html image tag in there. The function must be used in the loop to work. I'd do it like this: <?php ...



Only top voted, non community-wiki answers of a minimum length are eligible