How can I use a specific wordpress page template if certain words are used in page title [closed]

You can adjust the template to use in the fly based on the type of page you’re viewing. https://codex.wordpress.org/Plugin_API/Filter_Reference/template_include 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 ( ” != $new_template ) { return $new_template ; } } … Read more

Get a page ancestor from a most viewed list

get_ancestors will return array form value. So if you talking about how to get and display that ancestors with link: <?php $arrAncestors = get_ancestors( $post->ID, ‘page’); $cntAncestors = COUNT($arrAncestors); if($cntAncestors > 0) { $parentPostId = $arrAncestors[$cntAncestors – 1]; $parentPageLink = get_permalink($parentPostId); $parentTitle = get_the_title($parentPostId); print ‘<li><a href=”https://wordpress.stackexchange.com/questions/243836/<?php $parentPageLink ?>” title=”<?php $parentTitle; ?>”><?php $parentTitle; ?></a></li>’; } … Read more

Supress listing of virtual pages

The only way is to use the filter in the Recents from developer.wordpress.org WP_Widget_Recent_Posts::widget $r = new WP_Query( apply_filters( ‘widget_posts_args’, array( ‘posts_per_page’ => $number, ‘no_found_rows’ => true, ‘post_status’ => ‘publish’, ‘ignore_sticky_posts’ => true ) ) ); Best way will be, to add a category to the post your submit from frontend. add_filter(‘widget_posts_args’, ‘wpse_244383’); function wpse_244383(){ … Read more

Press This for Page

The press_this_save_post filter can be used to change the post type from post to page. Add the following code to your theme’s functions.php or a plugin: add_filter( ‘press_this_save_post’, ‘wpse244633_press_this_save_post’ ); /** * Filter the post data of a Press This post before saving/updating. * * @param array $post_data The post data. * @return array */ … Read more

problem with loading pages

It is impossible to guess what is breaking your site without hands on debug. In general to debug redirect issues I always recommend Better HTTP Redirects plugin, which has debug mode to stop redirects in process and help figure out which code is generating them.

WordPress Contents Migration

If your data diverged at one site (old site receiving new content) and your code diverged on another (staging site in development) then you don’t really have a conflict here. You can just update live site with new code, assuming things are reasonably compatible. In general WP is not friendly to bi–directional move of content. … Read more

How to insert current user ID in a shortcode?

You didn’t say how you were going to implement the code: If you are using page templates or custom post pages, you could do this: <?php $user_id = get_current_user_id(); if ($user_id == 0) { echo ‘You are currently not logged in.’; } else { echo do_shortcode(‘[pods-form name=”user” id=”‘.$user_id.'” fields=”my_field, my_field_2, my_field_3″]’); } ?> are you … Read more