Strip from the_tags() output

Well, you can use the DOM object to change/remove tags and their parameters. See here for all the details https://stackoverflow.com/questions/3820666/grabbing-the-href-attribute-of-an-a-element Code would be something like this: (this sample changes the class of all H1 elements to be ‘a_new_class’, removing any existing classes) $html = “<h1 class=”the_old_class”>A Heading</h1>”; $dom = new DOMDocument; libxml_use_internal_errors(false); // supress errors … Read more

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