Tag Info

New answers tagged

0

You could use the function wp_get_nav_menu_items() instead of wp_query() to retrieve the menu items from a particular menu in the menu structure order. Once you've done that, you could loop through the menu items one by one to do with as you wish (including filtering them down further on type or other info). This is assuming all pages are in the menu (which ...


0

You may be able to use a WP_Query on nav_menu_item since it is its own post type. I've never done this but maybe it would work like you need it to, worth a shot. There are three other possibilities: Option 1 - Get Your Nav Menu Items There's a functions called wp_get_nav_menu_items() which will return you an array of your menu items that you can then loop ...


0

Before reading the solution Bravokeyl provided I had finally, through trial and error, come up with a solution that worked for me. I'm not sure which is the better of the two, or the most correct, I only know that mine worked for me, for the problem I had. This is the code I used to display full-width layout or sidebar-menu layout: if( is_page() ...


1

Try add_action( 'admin_menu', 'wpse182102_register_my_custom_menu_page' ); function wpse182102_register_my_custom_menu_page() { add_pages_page(null, 'Menu Item Name', 'edit_posts',/* or whatever capability required for this object */ '/post.php?post='.get_page_by_title('Etusivu')->ID.'&action=edit', null, ''); } And change Etusivu to be the ...


0

Reread your question and revised the solution as well. It is a Page template now and should be set to the page that needs its content protected. It relies on a "login" post that has the html from. <?php /* Template Name: Protected Page */ // Standard HTML of Theme global $post; // check if authentication has been made if( ...


0

Level-0 --Level-1 ----Level-2 ------Level-3 ----Levelanother-2 --Levelanother-1 check whether page is top level page (it may have children or not) ? $post->$post_parent == 0 or is empty get_post_ancestors( $post ) returns only Level-0 Pages. Is a child page and is a Level-1 page or Levelanother-1 only ? $post->$post_parent > 0 or is not empty ...


2

If you give a look to get_template_part it says that <?php get_template_part( 'loop', 'index' ); ?> will do a PHP require() for the first file that exists among these, in this priority: wp-content/themes/twentytenchild/loop-index.php wp-content/themes/twentyten/loop-index.php wp-content/themes/twentytenchild/loop.php ...


1

Your output is expected, but before I come to the solution and why's, you have a couple of issues here You are either using query_posts or nullifying the main query global which you should never do. The give away is your loop (if (have_posts()) : while (have_posts()) : the_post();) and the use of wp_reset_query();. You should be using a proper instance of ...


0

There are two problems that I can see that cause your code to fail. The first is that you're using update_page_meta, which does not exist. Use update_post_meta instead. The second is that you're using the action save_page, which also does not exist. Use save_post, save_post is an action triggered whenever a post or page is created or updated, so it is ...


-1

try this way: add_action('save_post', 'wpse_181902', 10, 2); function wpse_181902($id, $item) { if ($item->post_type == 'page') { //Your custom logic update_page_meta( $id, 'bookinfo', $booktxt); } }


0

The best thing to do in this case is to do as follows: 1) Back up your entire website, all files and the SQL database 2) clear the database and delete all files 3) install a fresh version of wordpress completely new. 4) try to make a post. If it works, then you are in luck, the problem is not with your host. If not, then the problem is your host. (and ...


0

If I understood correctly you need to show a specific category index on a page template, right? If that's the case you can use WP_Query: <?php /* Template Name: My Page Template */ ?> <?php get_header(); ?> <!-- If you want to retrieve the page title, content, ... --> <?php the_post(); // set up the post ?> <h1> ...


0

You can get an array of child pages using get_children. Use the parent page's ID as post_parent. Once you have the array, you can loop through them and display whatever info you want. For example, to show the page title (linked) and the excerpt you could do: $args = array( 'post_parent' => $post -> ID ); $children = get_children( $args ); if( ...


0

Try to replace the following: <?php $sectyp = array( 'meta_query' => array( array( 'key' => 'section_type', // selecting the section type "Normal" or "Parallax" 'value' => 'Parallax' ), ), ); ?> with <?php $sectyp = ...


0

Two issues here The default page post type is page, not pages Your meta_query is wrong, it should be an array of an array, not just an array Your arguments should be $args = array( 'post_type' => 'page', 'order' => 'ASC', 'posts_per_page' => 50, 'meta_query' => array( array( 'key' ...


-1

You have to assign a page template for every page you create , for example if you have about page you can not just create about.php and expect it to work, for more help about creating templates or naming your pages check this link Wordpress Codex


0

You're probably getting that error because WordPress doesn't have the $wp_rewrite global loaded yet for some reason. Either something deactivated it, or you're trying to run those functions before WordPress has a chance to load it. If you're trying to do this in a plugin or in your theme's functions.php file, make sure you're inside a function that is ...


0

I don't think that's what should normally happen. Can you replicate that on a clean install with no plugins and a default theme?


0

You rarely ever need a custom SQL query, use the tools WordPress has to offer: $query = new WP_Query( array( 'posts_per_page' => -1, 'post_parent' => $post->ID, 'post_type' => 'page', 'orderby' => 'menu_order post_title', 'order' => 'ASC', ) ); if ( $query->have_posts() ) : ?> ...


2

I hope you understand what query variables is. If not, here is it in short. The main query uses WP_Query to set itself up. In the main query, WP_Query uses public query variables to construct the main query according to the page being requested, and paged and page are two of them. To see all the public query variables, paste this in your header and check on ...


0

Will get_pages() work for you? http://codex.wordpress.org/Function_Reference/get_pages If I'm understanding your question correctly, you would want something like this: $children_of_page = get_pages(array( 'child_of' => $post->ID, 'parent' => $post->ID //defining both parent and child forces the list to only include direct children. ...


0

I can - sort of - solve my problem by cheating. One of the reasons I don't want to dig around in the code in index.php is that it serves both as a sort of homepage for the blog and also as a search results page (in this site searching through posts is the only kind of search we care about). So on the menu I can point the href for the Blog link to ...


0

You can make use of the_page_content() outside the loop to display only the content of the page where the_page_content() is supported by the following function function the_page_content() { global $post; $content = ''; if ( is_page() ) { $content .= apply_filters( 'the_content', $post->post_content ); } echo $content; } ...


0

the_content(); I think this is what you're looking for?


0

A while ago I added a function to one of my sites to change a set of posts from one type to another. I can't remember exactly why, but I've dug it out and updated it a little, and it is tested and working. The function Place this in functions.php so that it can be called from anywhere within your blog. /** * Change the type of a WP_Post object * * ...


0

I'm a little confused about the current setup, but in general, I would suggest logging into your friend's WP Admin Dashboard and going to Appearances > Customize > Static Front Page and selecting the "New Home" page like so: If you are using any caching plugins, then also be sure to purge the cache from them so that you are able to see the updated home ...


1

You should get ID of the page you're looking for: $page = get_page_by_title('thank-you'); wp_redirect(get_permalink($page->ID)); exit; It looks like you want to get page by slug. If that's the case, you should use this function instead. Also, for Location header don't use space after "Location" string: header("Location: http://localhost/mysite/faq"); ...


1

I believe that this plugin will do what you want. Jamocreations Auto Submenu https://wordpress.org/plugins/auto-submenu/ Here is also a link to the author's site, http://jamocreations.com/en/artikelen/auto-submenu , where he discusses why he built the plugin and also two other plugins that also work similarly. The advantage of the Jamocreations Auto ...


0

Thanks to the theme developers for helping me fixing it. I'm posting the answer here in hope that it may helpes any person facing the same problem. In functions.php there was a code to disable comments on page.php Remove this part of code from functions.php to make the comments working on pages too: function default_comments_off( $data ) { if( ...


0

This approach is not advisable as http://example.com/page/whatever-information/ is how Wordpress deals with child pages and .htaccess Rewrites is part of how Wordpress identifies what page is being requested and what queries to run. You should probably pass the whatever-information as something called a POST variable, then have code that runs on page and ...


0

You should delete this part (as Pieter wrote): $the_query = array( 'paged' => $paged, 'cat' => $cat, 'posts_per_page' => 20, ); $arrgs = new WP_Query( $the_query ); $temp_query = $wp_query; $wp_query = NULL; $wp_query = $arrgs; I'm supposing that you want to show 20 posts per page, you could either configure that in ...



Top 50 recent answers are included