How to output functions from plugin inside theme

Looks like function render_content_show_hide() is a method of class. If you want access this function directly – you can create new class instance. If your plugin code looks like: class Shortcode_Builder{ //…methods public function render_content_show_hide( $attr, $content = null, $shortcode_name=”” ) { //… } //…other methods. } Create new instance $builder = new Shortcode_Builder(); And … Read more

Dropdown menu for categories

This will give you your desired result. <?php $list_categories = get_categories( $args ); echo “<div class=”container”>”; echo “<div class=”productsubmenu”>”; echo “<ul>”; foreach ($list_categories as $cat) { if($cat->category_parent == 0) { $category_id = $cat->term_id; echo ‘<li class=”parent ‘.$my.’ “><a href=”‘.get_term_link( $cat ) . ‘”>’.$cat->name.'</a>’; $args2 = array( ‘taxonomy’ => $taxonomy, ‘child_of’ => 0, ‘parent’ => $category_id, … Read more

post permalinks with dot in url don’t resolve to correct page template

I wound up using the index_template filter to load the right template when the CPT single page is being incorrectly redirected to the index and $_SERVER[‘REQUEST_URI’] contains the slug of the CPT. Like so: add_filter(‘index_template’, ‘wpse300393_resolve_cpts_with_dots_in_name’); function wpse300393_resolve_cpts_with_dots_in_name($templates=””){ if( strpos($_SERVER[‘REQUEST_URI’], ‘artwork’) !== false ){ $templates = locate_template( ‘single-artwork.php’ ); } elseif( strpos($_SERVER[‘REQUEST_URI’], ‘artist’) !== false … Read more

Modify available templates (in dropdown)

The list of available templates is generated by get_page_templates. By the end of this function you see a filter that allows you to modify the output. You can use that to change it under certain conditions like this: add_filter (‘theme_page_templates’,’wpse302574_conditional_templates’, 10, 4); function wpse302574_conditional_templates ($post_templates, $this, $post, $post_type) { $parent_id = wp_get_post_parent_id ($post->ID); if (get_page_template_slug … Read more

How to create custom search page

you dont need extra queries, all you would need is to sort the search results by post type. you can find a way to do so here. and then, inside your search.php template, you would need to check for the post-types and act accodringly.. while (have_posts()) : the_post(); $post_type = get_post_field( ‘post_type’, get_the_ID() ); if … Read more

How do I create a custom permalink structure for a page template

There are different filters available to create the custom permalinks for the posts, custom posts or pages: post_type_link – for custom post types post_link – only for post_types ‘post’ page_link – for pages only ( which you are looking for ) Here is the sample code based on your query: public function custom_permalink_for_page_template( $url, $post … Read more

get_page_template_slug returns incorrect path

I just checked what the function you called does and it just retrieves the _wp_page_template value from the wp_postmeta table of WordPress. So probably the structure of your theme is not right, some rewrites are active, or something else (e.g. plug-in) altered this database table. You could check that the theme root directory is indeed … Read more

Use same page-mypage.php template for several pages

To re-use the same template for different kinds of pages you can use the template_include filter. Example given from the docs: add_filter( ‘template_include’, ‘portfolio_page_template’, 99 ); function portfolio_page_template( $template ) { if ( is_page( ‘portfolio’ ) ) { $new_template = locate_template( array( ‘portfolio-page-template.php’ ) ); if ( !empty( $new_template ) ) { return $new_template; } … Read more

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