Tag Info

New answers tagged

0

Here is what I've done: I delete all of the pages that I had created just for the sake of grouping the sub-pages. All of the pages that were sub-pages are now regular pages, not sub-pages. I created a new menu. For each menu group, I created a custom link, and assigned as its url the url of what will be its first child. Within the menu, I created a ...


1

Important Link: Posts Creation Limits Dig into this plugin you easily get the code for limit posts/pages.


0

I upvoted @MattKey's answer because the back-end configurable menu system is a good way to deal with things like this, and also keeps the menus editable from the back-end. However... that answer does not directly answer the question of how you would do this based on the page structure alone. The answer I came up with is a custom Walker for wp_list_pages. ...


1

I would use the built in Wordpress Menu Manager (Appearance -> Menus) to create my menu structure. For each of the 'dummy' parent pages you can just use a second link to that pages first child page, and rename it to read however you want. So if your structure is: -Parent A Child A Child B Child C And you want to make it so that clicking on Parent A ...


0

Here is the code for menu with sub-menu from pages and child pages. <ul> <?php $parents = array(); $args = array( 'post_type' => 'page', 'parent' => -1, 'number' => '', ); $pages = get_pages($args); foreach( $pages as $page){ $childs = get_pages('child_of='.$page->ID); ...


0

Go to your style.css file in your current theme and look for #content{}. The first value of the margin is responsible for the gap at the top. Reduce the first value to close the gap, or set it completely to zero like this: #content { margin: 0; }


0

I believe you want get_queried_object. That will return information about the page per se and not necessarily about the posts/pages being displayed in the Loop. Be aware that it returns very different information depending on the type of page you are one. It will return user information on an author archive, for example, but category information on a ...


-1

Try is_single( $page_id ) instead. Basically is_post() has been deprecated. http://codex.wordpress.org/Function_Reference/is_single


0

For a hierarchical post type, you can use $post->post_parent and get_permalink(), perhaps like so: <?php global $post; $parent_permalink = get_permalink( $post->post_parent ); ?> <a href="<?php echo $parent_permalink; ?>">Parent Post</a>


0

the_content does echo the content. That is stated in the Codex-- "Displays the contents of the current post", emphasis mine. Use get_the_content instead, to return a string that you can manipulate. Be aware that get_the_content does not run all of the same filter as the_content. Again from the Codex: If you use plugins that filter content ...


0

@userabuser's input provides a useful discussion on using Custom Post Types to solve the customisation need. However, this still left unanswered my main question: Can I interrogate a pages template type or custom meta data within a loop? I wanted to use wordpress static pages with a custom template as an alternative to Custom Post Types. For the small ...


0

Brian Fegter's answer is almost perfect. In my testing his answer will only work if you change the actions to "wp_trash_post" and "before_delete_post" function restrict_post_deletion($post_ID){ $user = get_current_user_id(); $restricted_users = array(21,25,54,2,19); $restricted_pages = array(2,21,52,64); if(in_array($user, ...


1

I would create an "Events" custom post type and then create a "Call to Action" custom taxonomy and associate this taxonomy with the custom post type. This way you can have an unlimited amount of events which can be associated with taxonomy terms (your Call to Action). This makes much more sense since you project that you will have few Call to Action types ...


2

You are calling get_page_by_title( $page_title ) already. Use it! if ( ! get_page_by_title( _x( 'Homepage Template', 'home page title', 'your_theme_textdomain' ) ) ) { // create the page } Do not delete user content on theme deactivation. The user might have put much energy into that page, and maybe he is not aware you delete his work. But ...


3

The Navigation Menus system is adding a lot of classes, including matching current page (rather intelligently, it will even try to detect custom URLs, that were input explicitly). The simplest class to make use of is current-menu-item, but there are quite a few more dealing with parents/ancestors and more. Codex has them documented at wp_nav_menu() > Menu ...


3

PHP does not ever display in source, if things are working correctly. PHP executes on the server. If things are working the way they should you never see the PHP source. I don't know what your conditions are for this project, but the most straightforward way to access a script is to make a custom page template for it. You would ... create your template, ...


1

The wpdb object can be used to run arbitrary queries against the WordPress database. Let's say you want to list the most recent 4 posts: $results = $wpdb->get_results( "SELECT * FROM $wpdb->posts WHERE `post_type`='post' LIMIT 4" ); The $wpdb->posts variable will output the table name for posts. It's usually wp_posts, but if you're using a ...


0

I'm not entirely certain what you're asking. If you want to have the list of pages in an ordered list insted of unordered it should be simple: echo '<ol>'; wp_list_pages( array( 'title_li' => null ) ); echo '</ol>'; However if what you're asking is to order it according to some parameter so that you can shuffle it around, it looks easiest ...


3

You are under a fundamentally wrong assumption: The content you input via the administrative back-end does not live in a file, but in the database, specifically in the wp_posts table. Do not be misguided by the table's name, a "page" is technically a post of type page. If you attempted to find the content you created via your "hosting file manager", it is ...


1

You don't. The content of your Page is stored in the database, not in the PHP files.


2

That content is in the database, not in any template. The page that displays that database content could be page.php, or a custom template, depending on your theme and page.


0

You don't need to force the permalink structure to do this. These effects are usually handled by adding some class (with a specific style) to the item you want to highlight, in this case the <li> containing the link to the shop. In your site, the Shop menu entry (when in the Shop page) is: <li id="menu-item-23" class="menu-item ...


1

Put this in your functions.php: function my_title() { if (is_home()) echo 'News'; else { global $post; if ($post->post_parent) echo get_post($post->post_parent)->post_title; else echo $post->post_title; } } // function my_title and then use <?php my_title(); ?> anywhere you want. ...


-1

You can use the $args in get_children, but ensure you also specify the post ID that you want to retrieve children from, even if it is the current page children you want get_children( array( 'post_parent' => $post->ID, 'orderby' => 'menu_order', 'order' => 'ASC' ));


0

The template_redirect hook might be what you are looking for. function template_redir_wpse_97289($content) { // code or file include, for example } add_filter('template_redirect','template_redir_wpse_97289',1); That will fire just before the page template is loaded so you could use it to load your own templates.


0

Found it! check the code below: <?php if ( is_user_logged_in() ) { global $wpdb; $user = wp_get_current_user(); $where = get_posts_by_author_sql( 'page', true, $user->ID ); $count = $wpdb->get_var( "SELECT COUNT(*) FROM $wpdb->posts $where" ); if ( $count >= 1 ) { ?> //option 1 if ...


4

To list all pages with title and permalink from one user you need $wpdb->get_results(). The following code is based on this answer: How to count current user's pages? First, we move the counter into a separate helper function; we might need it later again: /** * Get all post IDs and titles of a type for a user. * * @param int $user_id * @param ...


2

<?php the_content(); ?> That's the function that displays everything you saved in Pages - > Contact Page. You just need to move that anywhere you would like. Just keep in mind the_content() must be between the while loop for it to work. <?php if (have_posts()) : while (have_posts()) : the_post(); ?> // Begins loop <?php endwhile; ?> // ...


1

This is my Solution, I used Onclick attributes for the radio buttons to change the 'actions' of elements within the form. <form id="searchme" action="<?php echo site_url(); ?>/postersearch" method="get"> <ul class=" four columns inline-list offset-by-one"> <li><label for="radio4"><input name="post_type" CHECKED ...


0

The answer of Alexander Poslavsky is correct. But i would like to say that at the bottom left of every page of simonsays websites has a ?> echo'd. I think that is not the meaning.



Top 50 recent answers are included