setcookie on WordPress Page Template

I am having an issue with setcookie. I need to set a cookie on a page action (form). I have tried on the template file, but not working. then find out if I set it from functions.php with init hook, it's working. then I put condition like if(is_page_template('mytemplate.php')){... then it's not working. how can I do that? here is my code. add_action( 'init', 'hello_my_cookie' ); function hello_my_cookie() { if(is_page_template('mytemplate.php')){ if(isset($_POST['GGmyCookie'])){ setcookie( 'myCookie','Hello Cookie!', time()+3600); } } }
Category: Web

registering a global template wordpress 6.0

<?php /* * Template Name : Amaizing Inner Page 1 Template from me* * @package WordPress * @subpackage CADENTIC® BUSINESS THEME * @since MY BUSINESS THEME 0.0.1 */ ?> if we would these simple lines in a template file we would use it as a global template but now in WordPress 6.0, there is no such attribute that exists in Gutenberg to select a new page template. I was following a few articles for this wordpress doc clouddera
Category: Web

Closing Paragraph Tag Missing in Wordoress

The closing P tag is stripped out of my blog posts whenever I use this code in my Functions.php file to insert an after a number of paragraphs. It leaves the unclosed. What could be wrong? // Article Ads After X Paragraphs ///////////////////////////////////// $mvp_post_inad = get_option('mvp_post_inad'); if (!empty($mvp_post_inad)) { function mvp_post_ad_insert( $text ) { if ( is_single() ) { $mvp_post_inad = get_option('mvp_post_inad'); if ($mvp_post_inad) { $ads_text = '<div class="mvp-post-ad-wrap"><span class="mvp-ad-label">' . esc_html__( 'Advertisement', 'zox-news' ) . '</span><div class="mvp-post-ad">'.do_shortcode(html_entity_decode($mvp_post_inad)).'</div></div>'; } $split_by …
Category: Web

A problem with functions.php file on my WordPress site

When I add functions.php file to my WordPress website, my website just stops working. It doesn't matter if I have or have not code there, whenever the functions.php file is present, the site stops working. I tried to check if there is any typo or parser error, but I can't find nothing nor the debugger doesn't report anything. This happens also when I follow tutorial in a book.
Category: Web

Magnific Popup - Add Caption to Images

My theme uses Magnific Popup as follows in theme.js /* add lightbox for blog galleries */ $(".gallery a[href$='.jpg'],.gallery a[href$='.jpeg'],.featured-item a[href$='.jpeg'],.featured-item a[href$='.gif'],.featured-item a[href$='.jpg'], .page-featured-item .slider a[href$='.jpg'], .page-featured-item a[href$='.jpg'],.page-featured-item .slider a[href$='.jpeg'], .page-featured-item a[href$='.jpeg'], .gallery a[href$='.png'], .gallery a[href$='.jpeg'], .gallery a[href$='.gif']").parent().magnificPopup({ delegate: 'a', type: 'image', tLoading: '<div class="loading dark"><i></i><i></i><i></i><i></i></div>', mainClass: 'my-mfp-zoom-in', gallery: { enabled: true, navigateByImgClick: true, preload: [0,1] // Will preload 0 - before current, and 1 after the current image }, image: { tError: '<a href="%url%">The image #%curr%</a> could not be loaded.', …
Category: Web

How do I turn off self-closing tags for markup in WordPress (for HTML5, or HTML4, for example)?

I want to use HTML5 in my WordPress theme, how do I turn off wptexturize? I don't mind WP adding breaks, but I want them to be <br> and not <br />. How do I get control over how those breaks show up in my code? EDIT: I only really care about the <br> tag issue, I don't mind the typographic changes it makes. EDIT2: Actually, I guess <img> tags matter too. Any self-closing standalone tags will matter here. So, …
Category: Web

Is there a way to opt out of or block having the newest core themes installed on update?

We generally keep our custom theme in non-auto-update mode and one core WP theme in auto-update mode as an emergency backup as our only 2 themes in the wp-content/themes directory. If we had twentytwenty installed when we launched the site in 2020, that's sufficient for our purposes - we don't need twentytwentyone and twentytwentytwo, etc. It's annoying to have to delete these manually after WP updates add them. Is there any way to block that from happening?
Category: Web

Use of undefined constant FS_CHMOD_DIR - assumed 'FS_CHMOD_DIR'

I'm seeing an error while trying to change the colours of a theme: Notice: Use of undefined constant FS_CHMOD_DIR - assumed 'FS_CHMOD_DIR' in /var/www/vhosts/xxx/wp-content/themes/consulting/inc/print_styles.php on line 141 The theme creator has given me the following advice, but cannot provide any further detail: Please contact your hosting provider team and ask to enable (set up) PHP FILE extension in your site. It will solve the problem. I manage my server, but I have also been in contact with my hosting provider, …
Category: Web

How to get rid of undefined variable in previous post image

I am working on a website on WordPress and I have it set to where the bottom of the post will automatically link to a random previous post with a picture from that previous link but a notice keeps popping up on the bottom. It says there is something wrong with the previous post image url but the website sets this automatically and it works for all my other posts. Since it is undefined should I try to define it …
Category: Web

Enqueue All Stylesheets Found In a Theme Folder

Is there a built-in Wordpress function that will allow you to enqueue all stylesheets for a particular theme? I have a directory structure that looks like: -my-custom-theme -css -header.css -footer.css -functions.php I want to load all CSS files found in the my-custom-theme/css folder
Category: Web

template_redirect() doesn't seem to be working

kind of a rookie question but here goes: I'm working on a Wordpress theme from scratch on my local machine, and I'm setting up a static page for the Blog. I have my archive.php file for all the posts and then a single.php for individual posts. However, when I put these files in my root folder (themes -> theme name), along with index.php, the file always seems to default to index.php. In addition to that, I was trying to use …
Category: Web

Sticky header for wordpress changes size and logo size as I scroll down

I am using Themify to construct my website. I have a parallax site partially constructed, however when I scroll down my logo and header changes size. It is a sticky header and goes from being transparent to a color. Where can I find the options to change this in the themify builder? I just want to keep the size consistent as I scroll down. Here is the site: http://willwiseman.us
Category: Web

How do I get the trackback count of a post in wordpress without writing an SQL query?

How do I get the trackback count of a post in wordpress without writing an SQL query? I tried searching Brave Search and I couldn't find anything helpful. To fetch the amount of comments a post has, get_comments_number() is the wordpress protocol function for it. But what if I want to fetch the amount of trackbacks a post has? And also, do I have to be inside "the loop" to do this? What if I'm outside the loop?
Category: Web

How to override theme's public static function inside of a trait?

I use a theme which has a public static function to display a part of a page like: trait SomeTrait { public static function some_function() { ?> <div class="some_class">Some content</div> <? } } and the helper file looks like: class Helper { use SomeTrait; // ... } I need to override the function in my plugin. In the plugin I try the code: /* Plugin Name: MyPlugin Description: - Version: 1.0 Author: - */ if ( ! defined( 'ABSPATH' ) …
Category: Web

Display a specific category in a focused area of my site

I've been trying to change the code of my WordPress site. Rather than showing "trending posts" which is determined by post_views_count, I simply want to show posts from a certain category. The code, as it stands is: if ( !function_exists( 'getCrunchifyPostViews' ) ) { function getCrunchifyPostViews($postID){ $count_key = 'post_views_count'; $count = get_post_meta($postID, $count_key, true); if($count==''){ delete_post_meta($postID, $count_key); add_post_meta($postID, $count_key, '0'); return "0 View"; } return $count.' Views'; } } if ( !function_exists( 'setCrunchifyPostViews' ) ) { function setCrunchifyPostViews($postID) { $count_key …
Category: Web

Can't add new plugin or themes on a wordpress multisite network from the primary site as administrator. Error: ERR_TOO_MANY_REDIRECTS

I can't add new plugins or themes on a wordpress multisite network from the primary site as super administrator. It shows this error: ERR_TOO_MANY_REDIRECTS. However, I am able to access all pages, login to each site's dashboard or even make changes to existing codes for installed plugins or themes. I am not able to install any new ones and the network is stuck in a loop. However, the problem can be avoided if I turn off the multisite option using …
Category: Web

All custom links suddenly lack href attributes

Short version: before updating to WP 4.5 and on a day when the only known change was adding a page to a submenu via the navigation menu admin all of the menu links of type Custom Link where we specify a URL suddenly lost their href attributes. Links of type Page still have theirs. After much experimentation I confirmed that deactivating all plugins did not change this but setting TwentyFifteen as theme corrected it. Theme authors are no longer available …
Category: Web

Show attribute description when filtering by that attribute

I’m setting up a woocommerce shop for my wife. In this shop, the brands mean a lot to us so we’ve added descriptions for each brand. A nice little story with an image and everything. Now when I click the brand-attribute from a single product page, I go to http://www.webshop.com/brand/brand-attribute which show the description above some products. Is there a way to make this work with filters as well? So I’m in the shop and when I filter on brand …
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.