Tag Info

New answers tagged

0

Like the front-end in WordPress, the admin pages have various css classes added to the <body> tag. You could use: body.post_type-page .fun-stuff-here { color:aqua; } Keep your action the same - the CSS will be loaded everywhere on admin, but only becomes relevant in the Pages section. (There's a post_type-... for each.)


0

I was having the same kind of problem, eventually I fixed it by calling the main css file of the front-end and making specific ID's for the admin-only stuffs like so: function your_css() { wp_register_style('your_css', plugins_url('style.css',__FILE__ )); wp_enqueue_style('your_css'); } add_action( 'init','your_css'); the wp_register_style & ...


0

You should use http://example.com/page-slug/ where page-slug is page created by make Query.php as template. <form action="http://example.com/page-slug/" enctype="multipart/form-data" method="post" name="contact">


0

Wp Hide Post plugin will help you - https://wordpress.org/plugins/wp-hide-post/ This plugin has ability to hide a specific post on "Home Page or Category Page or Archive Page" etc. In your case create a category Technical Notes, add this to you nav menu or wherever you want. After installing the plugin, you'll see a new options has added at the right side ...


-1

Found a method! echo '<META HTTP-EQUIV="REFRESH" CONTENT="3">' ;


0

I figured it out. It looks as if the Codex never referenced the one parameter I needed to make it work in the Codex. I checked out this site here for a full list of parameters in the arrays http://www.billerickson.net/code/wp_query-arguments/ I needed to use post_parent and not child_of or parent. Fixed.


0

You do this with URL Rewriting. Locate your .htaccess file and add this line above # BEGIN WordPress RewriteEngine On RewriteRule ^author/(.*)$ /team/$1 [R=301,NC,L] Note, if you put this inside the wordpress block it will get rewritten next time your permalinks are regenerated.


0

The 'init' action runs everytime WP loads. You should be using 'register_activation_hook' for the functions that you want to run on plugin activation. register_activation_hook( __FILE__, 'insert_page' ); function insert_page(){ // Create post object $my_post = array( 'post_title' => 'My post', 'post_content' => 'This is my ...


0

First, throw away your custom walker. Post URLs are called permalinks, and as with most things in WordPress, you can filter them! There is a filter called post_link that lets you modify the URL of the post before it's returned in get_permalink(). We can use this, along with the posts slug, and the home_url function to get something similar to this: ...


0

You can add any default content you like, but I don't know of a way of doing it just for Pages (the following will apply to both Pages and Posts): add_filter( 'default_content', 'my_default_post_content' ); function my_default_post_content( $content ) { $content = "Hello World!"; return $content; } (place this in your functions.php file)


2

Filters should return, not echo. function my_content( $content ) { // Something something $content = 'my content'; return $content; } add_filter( 'the_content', 'my_content' ); You can echo, but you'll need output buffering, like this: function my_content( $content ) { // Something something ob_start(); echo 'my content'; ...


0

Please User Role Permission Plugin For user wise Permission Link here


0

Well, what do you know -- there's a plugin for that: https://wordpress.org/plugins/redirection/ Under the "redirects" tab in the plugin's settings you can set as many redirect rules as you'd like.


0

So thanks for your help. Now i pay more attention to functions.php so my old code have effectively. /* Change page order */ add_filter( 'pre_get_posts' , 'my_change_order' ); function my_change_order( $query ) { // Check if the query is for an archive if($query->is_archive) // Query was for archive, then set order $query->set( 'order' , ...


0

You can use pre_get_posts in your functions file for this with the WP_Query order and orderby parameters. function alter_query( $query ) { if ( $query->is_archive() && $query->is_main_query() && !is_admin()) { $query->set( 'posts_per_page', 100 ); } } add_action( 'pre_get_posts', 'alter_query' );


1

It depends on the theme. Most themes provide a composer (like Visual Composer) to adjust page content. If your theme doesn't work with a composer, you have to change the server files. Take a look at the child theme workaround then.


0

The easiest way to do it is to not use pages for that, but instead create a new post types for "hills" and/or "australia" this can be a PITA but you need to understand that the combination of post type and slug should be unique (the reason it is done this way is to let you change the permalink structure without having to update whole of the content). ...


1

No, no you cannot. Once a slug is used by a page, it cannot be used by other pages. It also can't be used by other posts, regardless of post types There is a Trac ticket on WP Core that's attempting to fix this so that a slug can be reused by post type, but that would still only allow you one use of your page slug. The chances that you could do what you're ...


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


1

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); } }



Top 50 recent answers are included