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

Fetch posts from category in custom page template

You can use WP_Query instead the get_posts() function: $args = array( ‘numberposts’ => 20, ‘category_name’ => ‘sell-items’ ); $wp_query = new WP_Query($args); if ($wp_query->have_posts()) : while($wp_query->have_posts()) : $wp_query->the_post(); echo ‘<li><a href=”‘.get_the_permalink().'”>’.get_the_title().'</a></li>’; endwhile; endif;

get_term_link() returns incorrect url

WordPress allows for customization of the default URL rewrite behavior (/slug/term) with a rewrite arguments array passed to the register_taxonomy() function. By defining values for the slug or hierarchical keys in this array, the default URL structure can be altered to suit your needs. It may also be altered such that unexpected results are returned. … Read more