How to switch between two primary menus (programatically0

You can try this code in specific page template function change_primary_menu( $menu ) { // you can check spesific menu id using this print and after that assign in, // and you can also check menu location using this print too echo ‘<pre>’; print_r($menu) ; echo ‘</pre>’; $user = wp_get_current_user(); //in this example im check … Read more

HTML Formatting “single_term_title()”?

There’s nothing about single_term_title(), or any WordPress template tags, that would prevent surrounding HTML from formatting it correctly. All these tags do is output their value. The formatting and appearance of that text is determined by the HTML that is surrounding it, and what your CSS rules are, according to the standard rules of HTML … Read more

How to call a WP Class inside my theme

You should be able to do something like this: $wp_customize = new \WP_Customize_Manager(); …since, as I understand it, WordPress core puts all its classes, functions, etc. in the global namespace. Edit It appears that $wp_customize may be a bad example, as it’s a global variable (so, in your theme, all you should need to do … Read more

How to put a before and after with tags in a wordpress entry?

You can use get_adjacent_post() to get the nexy/prev post by tag. I think this should work, // get_adjacent_post( $in_same_term, $excluded_terms, $previous, $taxonomy ) $next_post = get_adjacent_post( true, ”, false, ‘post_tag’ ); $prev_post = get_adjacent_post( true, ”, true, ‘post_tag’ ); if ( $prev_post instanceof WP_Post ) { printf( ‘<div class=”alignleft”><a href=”https://wordpress.stackexchange.com/questions/345428/%s”>&laquo; %s</a></div>’, esc_url( get_permalink( $prev_post->ID ) … Read more