How to set custom cookies in WordPress after a form is filled on a page

Your page-xyz.php has to look like this: $cookie_set = isset( $_COOKIE[‘mycookie’] ); if ( $_SERVER[‘REQUEST_METHOD’] == ‘POST’ ) : // exec your mysql queries and do else stuff… // after it set your cookie setcookie(‘mycookie’, ‘some value’); $cookie_set = true; endif; if ( $cookie_set ) : // render your content here else : // render … Read more

Function to load correct CSS for Template not working

I think your big problem here is your use of underscores (_) in your page template names. According to the Handbook of Coding Standards Files should be named descriptively using lowercase letters. Hyphens should separate words. my-plugin-name.php Also, for best practices you should call your custom page templates page-whatever.php So for instance, index_page.php should be … Read more

Custom page template to sidebar/widget

Use a shortcode include plugin and simply add a shortcode inside a text widget in the sidebar you’ll be using on the widgets or customizer page. Here are some example plugins and how they work: Include Me – [includeme file=”filename.php”] Custom Content Shortcode – [load file=template/sidebar.html] Insert Pages Plugin – [insert page=”{slug}|{id}” display=’title|link|content|all|{custom-template.php}’] Include Shortcode … Read more

Template Redirect to /2015 to use page template

If you really want to override the yearly archive for 2015, then you can try the following: add_filter( ‘template_include’, function( $template ) { //————————- // Edit this to your needs: //————————- $year = 2015; $report_template = “tpl-annual-report-{$year}.php”; //———————————————- // Override the default yearly archive template //———————————————- if ( is_year() // Yearly archive && $year == … Read more

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