Add a new page to wordpress programmatically
Yes, it’s wp_insert_post().
Yes, it’s wp_insert_post().
You can’t change dashes using any filter because there is no filter available to change it. but still you can change this using jQuery put this code inside functions.php add_action(‘admin_head’,function(){ global $pagenow; // check current page. if( $pagenow == ‘edit.php’ ){ ?> <script> jQuery(function($){ var post_title = $(‘.wp-list-table’).find(‘a.row-title’); $.each(post_title,function(index,em){ var text = $(em).html(); // Replace … Read more
You’ll need to do some .htaccess-fu to get what you’re proposing to work. RewriteCond $1 ^/labs/(.+) RewriteRule ^/labs/(.*)$ /labs-folder/$1 [L] This isn’t tested yet but it if you put it before the wordpress rules in your htaccess file it will remap urls that begin with /labs/ to /labs-folder/ but not if the url is just … Read more
Start with downloading the plugin called Force Post Title. Here’s the plugin with one row (2 with the comment line) added to the bottom, based on our comments. What happens is that a small jQuery script is added to the page Create Post/Page. The script will check if the title field is empty when the … Read more
Use ‘orderby’ => ‘title menu_order’ or &orderby=title menu_order (depending of the syntax you use for your query parameters).
if the result you’re looking for is a printout of the URL, like in your example, then this should work: $page_id = get_queried_object_id(); if ( has_post_thumbnail( $page_id ) ) : $image_array = wp_get_attachment_image_src( get_post_thumbnail_id( $page_id ), ‘optional-size’ ); $image = $image_array[0]; else : $image = get_template_directory_uri() . ‘/images/default-background.jpg’; endif; echo $image;
There is no specifica template for child pages, but you can do this pretty easily with the get_template_part() function. First create a file called “content-child.php”. Second create a file called “content.php”. Next, inside of page.php, place this: if( $post->post_parent !== 0 ) { get_template_part(‘content’, ‘child’); } else { get_template_part(‘content’); } Anything that you want displayed … Read more
You could maybe choose to use a tree like that: Fruits Color1 Apple Watermelon Color2 Banana Lemon Level1 Level2 Level3 This way, you can, in your theme, hide the second level. Hope that helps.
The code used to make this decision by WordPress is get_page_template(). The pagename version (page-{slug}.php) is pulled from get_query_var( ‘pagename’ ), you can use this in your page.php template to see what it outputs when visiting the child page. <?php echo get_query_var( ‘pagename’ ); ?> This mostly just means that the parent slug is ignored … Read more
You can use history.pushState to change the browser URL without reloading a page, and jQuery’s scrollTop method to scroll to the top of a specific element (and there are VanillaJS equivalents too). This will mimic the functionality of # anchors. However, like what Mark said, what your client wants is really weird. It is hard … Read more