Redirect to a different page through registration, depending on page

Changing the function to the following works, as it checks to see if the form was submitted from the correct page: function my_foo_registration_redirect( $redirect_to) { if ($_SERVER[‘HTTP_REFERER’] !== get_the_permalink(1693)) { return $redirect_to; } $redirect_to = ‘/videoguide-startpakke’; return $redirect_to; } Thanks a lot for the super helpful comments! EDIT: Here’s a slightly more polished solution function … Read more

Get posts from a custom post type by child categories of a parent category

Your start looks already ok. You now need to get the posts which have the term_id of your $category. $categories = get_categories( array( ‘orderby’ => ‘name’, ‘child_of’ => 87, ‘order’ => ‘ASC’ ) ); foreach( $categories as $category ) { // display current term name echo $category->name; // display current term description, if there is … Read more

how to delete 30 day old data using PHP [closed]

You’re adding an extra wp_ prefix to your table and your using a timestamp instead of a MYSQL datetime. Below is how WP suggests you use $wpdb->query to delete rows, taken from the codex. EDITED global $wpdb; $wpdb->query( “DELETE FROM ” . $wpdb->prefix . “userinfo WHERE timeall < DATE_SUB(CURDATE(),INTERVAL 30 DAY)” ); $wpdb->prefix adds the … Read more

Ajax not working es expected (Returns 0)

Please try this: Add the following in your theme’s functions.php add_action( ‘init’, ‘tnc_aj_scripts’ ); function tnc_aj_scripts() { wp_register_script( “ajax_anmeldung_script”, get_template_directory_uri(). ‘/my-ajax.js’, array(‘jquery’), ‘1.0’, true); wp_localize_script( ‘ajax_anmeldung_script’, ‘mYAjax’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’ ))); wp_enqueue_script( ‘jquery’ ); wp_enqueue_script( ‘ajax_anmeldung_script’ ); } add_action(“wp_ajax_ajax_anmeldung”, “ajax_anmeldung”); add_action(“wp_ajax_nopriv_ajax_anmeldung”, “ajax_anmeldung”); function ajax_anmeldung() { $result[‘one’] = ‘Hey’; $result = json_encode($result); echo $result; … Read more

Nesting if statements to echo only one string based on what tag was filtered?

is_tag() returns whether the query is for an existing tag archive page. This isn’t what you want to use. Instead, use get_query_var(). get_query_var( ‘tag’ ) will look at the tag query variable in the URL. For instance, if your URL is https://example.com/?tag=this&other=that then using: get_query_var( ‘tag’ ) will return this get_query_var( ‘other’ ) with return … Read more

Conditional Header in wordpress

It seems that you have forgotten to use <?php and ?> properly. Remember to open and close the php tag like the following: <?php if ( is_singular( array( ‘rivista’, ‘rivista-trimestrale’ ) ) ) {?> <script> jQuery(function($){ $(‘.parallax-window’).parallax({imageSrc: ‘<?php echo $ilgelo_options[‘ilgelo-parallax-image’][‘url’];?>’}); }); </script><?php } else { ?> <script> jQuery(function($){ $(‘.parallax-window’).parallax({imageSrc: ‘STYLESHEETPATH.”/img/header-rivista.jpg”‘}); }); </script><?php } ?>

How do you use WP slugs for PDF files / media?

In my opinion it is best to add an endpoint of the form mysite.com/pdf/<id> or something similar to your like. That way you avoiding attaching the attachments to posts/pages or create a page for each pdf file with is redundant imo for your needs. This is a very small and basic guide. You can modify … Read more

Multiple WordPress Menus that will only display all pages

The keys for the array passed to register_nav_menus() should correspond with the ‘theme_location’ arguments in your calls to wp_nav_menu(). Since they do not, WordPress is unable to locate the appropriate menu and displays a default consisting of all top-level pages instead. Either change your ‘theme_location’ arguments to ‘menu-1’ and ‘menu-2’ or change the array keys … Read more