Dynamically change page that loads

Wp load pages based on it’s main query. SO if you want to load a different page, then you may have to alter the main query with th e pre_get_posts hook.If you want to know more.Then please specif what and how you want to load different page in details

Dynamically generate child-URLs for posts or custom posts

I just completed something like this (with great help from folks on this site). First, you need to add the rewrite endpoint to your functions: function wpa_read_endpoint(){ add_rewrite_endpoint( ‘sub-url’, EP_PERMALINK); } add_action( ‘init’, ‘wpa_read_endpoint’ ); Make sure to then go to the permalinks section of admin and save to refresh permalink settings. Then add some … Read more

get_page_template returning nothing

Have you tried is_front_page()? It should do what you’re looking to do. Unless you’ve set up front-page.php with the Page Template commented header syntax that identifies the file is a Page Template, I don’t think you can use the is_page_template() or get_page_template() functions. As for the category page, if you are loading category-foo.php, then aren’t … Read more

Create a custom page template inside my wordpress plugin

You will create a page template whose file name is custompage-template.php here I suppose put in in your plugin dir/views/ folder. Whenever the page whose title is Your Page Name is visited, the site will render your custom template add_filter( ‘page_template’, ‘fw_reserve_page_template’ ); function fw_reserve_page_template( $page_template ) { if ( is_page( ‘Your Page Name’ ) … Read more

Calling custom plugin class methods from a template

You can just instantiate an object from class CustomPlugin like $obj = new CustomPlugin(‘id’,’name’,’desc’); in CustomPluginTemplate.php and call any method from the class within the CustomPluginTemplate.php file as $obj->query_vars(); Before instantiating make sure you class is included.

Creating a new page template

Try this instead: <?php /** * Template name: About Us */ WordPress could be finicky about the short tags (<? vs <?php) and comment formatting – shouldn’t be, but better safe than sorry. Also, make sure that you have the Screen Option to display Page Attributes turned on and that you’re on Add New Page, … Read more

Implement content-nosidebar.php / content-leftsidebar.php

Add this in your functions.php if( !function_exists( ‘my_custom_widgetize_theme’ ) ){ add_action ( ‘after_setup_theme’, ‘my_custom_widgetize_theme’, 10 ); function my_custom_widgetize_theme(){ register_sidebar(array( ‘name’ => ‘My SideBar’, ‘id’ => ‘my_sidebar’, ‘description’ => ‘This is the widgetized Side Bar.’, ‘before_widget’ => ‘<div id=”%1$s” class=”widget %2$s”>’, ‘after_widget’ => ‘</div>’, ‘before_title’ => ‘<h4>’, ‘after_title’ => ‘</h4>’ )); } } //this will be … Read more

WordPress shortcode display as plain text

First of all as far as I know that you can’t call get_template_part() from your plugin.It’s a Theme only function . Try to keep your calculator code’s in a php file inside your plugin’s directory and include it like bellow: function info_box_calculator_core(){ include( plugin_dir_path( __FILE__ ) . ‘mydir/calculator.php’); //replace ‘mydir/calculator.php’ with your file name } … Read more

Is there any way to get all the name or slug of template parts used in a page?

You could filter the include paths returned by get_included_files by removing any files from the list that are not in your theme (and/or child theme) directory: function get_theme_includes() { $includedfiles = get_included_files(); // normalize theme paths for matching $styledir = str_replace(“\\”,”https://wordpress.stackexchange.com/”,get_stylesheet_directory()); $templatedir = str_replace(“\\”,”https://wordpress.stackexchange.com/”,get_template_directory()); $i = 0; // loop included files foreach ($includedfiles as $includedfile) … Read more

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