Tag Info

New answers tagged

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 ...


0

When you save permalink settings, is there the following notification at the bottom of page? If your .htaccess file were writable, we could do this automatically, but it isn’t so these are the mod_rewrite rules you should have in your .htaccess file. Click in the field and press CTRL + a to select all. I'm asking because the behaviour you ...


0

Your question isn't particularly clear I'm afraid, but it sounds to me like you are trying to override the default template. For example, you still want the contents of your page to be displayed, but you don't want to use the default page.php template. If I am correct (please let me know in the comments if not), then there are two ways to do this. ...


0

To display published pages by default on pages link, simply paste this code snippet in your functions.php. You can then visit “All” tab to see full list of pages. // change page link to display published pages only function wcs_change_admin_page_link() { global $submenu; $submenu['edit.php?post_type=page'][5][2] = ...


1

Wp load pages based on it's main query. SO if you want to load a different page, then you may have to alter the main query with th e pre_get_posts hook.If you want to know more.Then please specif what and how you want to load different page in details


1

When working with shortcode you must return a value rather than output directly. The below amendmetn should fix your positioning issue. For more informaiont, see the Shortcode API Codex, speciffically the Output section. function multipage_form() { global $wpdb; $this_page = $_SERVER['REQUEST_URI']; $page = $_POST['page']; ...


0

You should check out the options from this theme. Probably you can set all this in the theme options. Accordion to the demo pages from The7 theme page you can choose for a list layout i.o a grid layout http://the7.dream-demo.com/blog/blog-list/5-blog-list/


1

Unless I am completely misunderstanding what you are trying to do, there is no need to move your site into a sub-folder. The easiest way to do what you want is to simply create your static page in normal html just as you want it to appear. Then add the following code to the very top of your page... <?php /* Template Name: Front Page */ ?> Then ...


0

You should understand that the theme editor is used to change the code structure of the pages something that cannot be achieved by simply creating a page via dashboard. These are two very different things, while you can add html on your page using the page editor you cannot add some Php there. In simple terms theme editor allows you to edit the structure ...


3

I'm the author of that plugin and I can confirm there was an issue. It was in the GM\VirtualPages\TemplateLoader::init(); method. Issue was caused by an untested switch from array_merge to wp_parse_args. They are similar, but I would have to inverse order of arguments moving from one to the other. Shame on me. I fixed that in the Gist (source) now it ...


0

On the staging server, in your wp-config.php define( 'WP_SITEURL', 'http://SERVER_IP/projectname' ); define( 'WP_HOME', WP_SITEURL ); Then: Place an empty .htaccess in /projectname Load http://SERVER_IP/projectname/wp-admin/options-permalink.php Check .htaccess - have rewrite rules been added?


0

The only way I can see this working is by setting a couple of redirect rules in your .htaccess file. You'd have to manually redirect all your posts (that you want with that permalink structure) and prepend the /awesome URL part in front. Other than the aforementioned solution, which is a hack more than anything, I'm afraid that what you're looking for is ...


0

You can query pages that have same parent excluding the page itself: wp_list_pages('title_li=&child_of='.$post->post_parent.'&exclude='.$post->ID); Use parent instead of child_of to get only direct siblings without children of the siblings.


0

I think i have a function that will do it for you. The usual WP way to highlight the menu item is to add the class "current-menu-item" to the item, then you can style highlighted links with CSS. In this case you want to highlight a taxonomy menu link if we're in a post for that taxonomy, is that right? For example if we're in a post in "CategoryX" we want ...


0

You could try to add this to your .htaccess file: Redirect 301 http://domain.com/wp-login.php http://domain.com/profile/login Redirect 301 http://domain.com/wp-login.php?action=register http://domain.com/profile/register Hope it helps.


0

For custom page templates, I would use page_about.php or page_services.php. Make sure you add the following after the opening PHP tag: /* Template Name: About Page */ Custom page templates can be uploaded to your themes root directory or a sub folder named page-templates. If creating a page template for a specific page, use the following: ...


0

Can you elaborate on the use-case? As Brad stated, using hooks is the the best method to accomplish this functionally. You probably would want to create a plugin that you could maintain, upgrade and reuse... especially if this is for a client! http://codex.wordpress.org/Writing_a_Plugin


1

Rather than insert PHP scripts into each page what you could do is execute PHP scripts using action hooks with conditional tags or modify the default output of an existing function using a filter hook with conditional tag for each page. You could also create template tags or write your own functions in a separate file and execute on any page in a custom ...


0

Every page can use it's own individual template if needed, have a look at the wordpress template heirarchy image for a bit more info. Basically a page will default to using page.php but if you provide page-{slug}.php where {slug} is the slug of the page, it will use that template instead. So it's entirely feasible to have a separate 'page' file for each and ...


0

<div class="page-section clear"> <div class="single-image-anchor"> <?php if (get_option( 'page_for_posts' ) ): ?> <?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( get_option( 'page_for_posts' )), 'single-post-thumbnail' ); ?> <div ...


0

Is this what you are after? <?php if($post->post_parent) { // if $post has parent than it is "Second level" and show its children. $children = wp_list_pages("child_of=".$post->post_parent."&echo=0"); } else { // else it's a "Top level" so display children & grand children? $children = ...


0

Just further on @Matthew Boynes answer, if you're interested in getting the parent slug (if any) also then I've found this function useful: function mytheme_get_slugs() { if ( $link = get_permalink() ) { $link = str_replace( home_url( '/' ), '', $link ); if ( ( $len = strlen( $link ) ) > 0 && $link[$len - 1] == '/' ) { ...


0

One example is Twenty Fifteen which uses a template tag in the content.php files like this: twentyfifteen_post_thumbnail(); And then the function for the template tag in inc/template-tags.php: if ( ! function_exists( 'twentyfifteen_post_thumbnail' ) ) : /** * Display an optional post thumbnail. * * Wraps the post thumbnail in an anchor element on ...


0

From your query (noted in the comments above), the page you are looking at believes that it is your home page (e.g. your blog). Notice in the wp_query object the following [found_posts] => 8 [is_home] => 1 is_home signifies that it believes that it is showing the home page. If your files are set up as you say, you should check your admin panel ...


1

The code below will work, read inline comments. Paste it into your theme functions.php or plugin. The only problem with this is the it will only work when the template is selected and the post is saved/updated and the editor is blank. <?php function wpse_177576_update_editor_content( $post_id ) { if ( wp_is_post_revision( $post_id ) ) ...


0

You could do this in two ways. 1) Leave the pages as separate pages in the WordPress dashboard and create a custom page template that lists those pages content. Assign this custom template to the homepage. 2) Move the content of those pages into the homepage editor. Option 1: A much cleaner option and allows you to revert to individual pages at a later ...


0

I am really quite unsure what is causing this unexpected behavior as you said it worked and then suddently it started with this issue. You will need to turn on debugging, disable plugins and check for any custom filters etc which might be causing this. Also, consider the possibility that Wordpress core got corrupted by something. If you suspect something ...


0

Here is a basic idea: Any page where the page parent ($post->post_parent) is 0, it means the page is a top level page. If any other value exists, the page is a child of another page. This value is the ID of the page that the specific page is a child to. With the above information, we can calculate if the page is a child or a granchild using get_post and ...


0

before your code, try and add: <?php if( is_home() && get_option( 'page_for_posts' ) ) { $posts_page = get_post( 'get_option( 'page_for_posts' ) ); echo apply_filters( 'the_content', $posts_page->post_content ); } ?> http://codex.wordpress.org/Function_Reference/is_home http://codex.wordpress.org/Option_Reference#Reading ...


0

I think you have created a page template to display posts on a page. You can try once this code to display your post with all its tags. Paste this code on your page template and create a page from admin and select the templates which you have created. <?php $the_query = new WP_Query( 'showposts=5' ); while ($the_query -> have_posts()) : $the_query ...


0

First you've to know what you want to retrieve, you will have to find something identical for that group of post you want to retrieve. Use the following code to retrieve the post, where $args is the variable what contains the arguments to select the right post ids. $posts = get_posts($args); $terms=array(); foreach($posts as $post) { //Get all terms ...


0

You need to do it for each post, how to archive the post ids depends on how you get them (loop or list or ... ). wp_get_post_tags() only can be used for one id. therefore it needed to be called 3times one solution could be $id1=1; $id2=2; $id3=3; $tag_ids = array(); $tag_ids[] = wp_get_post_tags( $id1, array( 'fields' => 'name' ) ); $tag_ids[] = ...


1

Edited answer Thank you for you clarification above, and please give this a try - Note - This code assumes that you are using page.php, a variation of the page templage or some other custom template - it will not work on your index page (index.php). <div id="page-<?php the_ID(); ?>"> <?php if (have_posts()) : while (have_posts()) : ...


2

Found the following solution which works to remove the content editor from all "page" content. Just chuck it in the functions.php file add_action('admin_init', 'remove_textarea'); function remove_textarea() { remove_post_type_support( 'page', 'editor' ); }



Top 50 recent answers are included