posts page – different lengths of excerpt

First, you need to filter excerpt_length. Assuming you want your default excerpt length to be 50 words: <?php function wpse53485_filter_excerpt_length( $length ) { return 50; } add_filter( ‘excerpt_length’, ‘wpse53485_filter_excerpt_length’ ); ?> That will make all excerpts 50 words. Make sure that works first. Then, add in an appropriate conditional, to use a different excerpt length … Read more

How to have a custom display for both woocommerce archive and product-category pages? [closed]

Generally, you can tell WordPress to load a different template. The mostly seen approaches make either use of the template_redirect or the template_include hook. It is preferable to use template_include as described in this article. Following an example on how to approach this: Code: // load the woocommerce category archive template add_filter( ‘template_include’, ‘wpse138858_woocommerce_category_archive_template’ ); … Read more

How to customize search result page title?

Within the wp_get_document_title() function we have: // If it’s a search, use a dynamic search results title. } elseif ( is_search() ) { /* translators: %s: search phrase */ $title[‘title’] = sprintf( __( ‘Search Results for &#8220;%s&#8221;’ ), get_search_query() ); so you could hook into the document_title_parts filter to adjust it to your neds. Example: … Read more

Restrict a search to a custom post type

You can restrict a search to a custom post type by modifying a basic WP search form like this: <form id=”cptsearch” action=”<?php echo home_url(); ?>” method=”get”> <input type=”text” name=”s” /> <input type=”hidden” name=”post_type” value=”POSTTYPENAME” /> <input id=”searchsubmit” type=”submit” alt=”Search” value=”Search” /> </form> To select a specialized template for the custom post type search, add this … Read more

Gutenberg & Pre-formatted Templates: Core Block Attributes

To partly answer my own question: As mentioned in this git issue you can use console.log(wp.blocks.getBlockTypes()); in the browser console after all the Gutenberg magic loaded (e.g. in the editor window of a post) to show all currently registered blocks, inluding their attributes. Another Info-Source: The Git-Project of Gutenberg holds all core blocks and their … Read more

Tools for Converting an Existing Website Design to a WordPress Template?

Here is a free and good step by step tutorial with video. How To Convert an XHTML Website Template into a WordPress Theme http://www.jonbishop.com/2010/03/convert-html-wordpress/ There are many tools on market which claims to PSD/Xhtml 2 WordPress http://www.divine-project.com/ http://www.artisteer.com/ http://www.artisteer.com/ but coding manually is the best way. No quick way to get custom and great themes.

How to hide/redirect the author page

You can do this at an earlier moment by hooking into the right action, like template_redirect, which fires right before the template will be displayed. add_action( ‘template_redirect’, ‘wpse14047_template_redirect’ ); function wpse14047_template_redirect() { if ( is_author() ) { $id = get_query_var( ‘author’ ); // get_usernumposts() is deprecated since 3.0 $post_count = count_user_posts( $id ); if ( … Read more

Programmatically change post templates?

I take it that you mean saving the pages with a new post-template to the DB? see if there’s anything in the post object that refers to the page-template, if so craft a query that updates that. Update: Taken from the wp_insert_post documentation NOTE: The page_template key was removed from the $post table and is … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)