How to use theme function in post/page?

Whenever using any WordPress function with get_xyz_etc() make sure you ECHO the function if you want to output the value there: <img class=”first-slide” src=”https://wordpress.stackexchange.com/questions/203434/<?php echo get_template_directory_uri() .”/images/landing-banner.png’; ?>” alt=”First slide”> It will now output the path!

How do I hook into the container of wp_nav_menu?

Solved it by setting container to false and then wrapping it manually. <nav class=”main_navigation”> <div class=”topper”> <a href=”https://wordpress.stackexchange.com/questions/203496/<?=get_home_url()?>” class=”intranet”>H</a> </div> <?php wp_nav_menu(array(‘container’=>false) ?> </nav>

Pagination on Custom Post

When you use WP_Query to get post from database, you must have to use next_posts_link() with max_num_pages parameter for our current query. You can do this as below. <?php next_posts_link(‘More &raquo;’, $packages->max_num_pages) ?> Now your code will become this. I have made above changes in following code. <div class=”eight columns”> <ul> <?php $paged = (get_query_var(‘paged’)) … Read more

Disabling visual editor on a specific post

I’ve tested the code you provided both WITH and WITHOUT the WP Editor plugin enabled and the “Visual” tab is suppressed in both cases. This means the user is forced into “Text” mode on post 416. To address your second request, I’ve modified the code to allow you to supply a list of posts that … Read more

hide shortcode using hooks

Instead of removing the shortcode, re-register it with a function that returns an empty string (or something that casts to an empty string). You can use the built in __return_empty_string. This will replace whatever the original callback was with something that just replaces the shortcode with nothing. // sometime after the first call to add_shortcode … Read more

New functions in separate directory — better, portable way

I’d say that the thing you’re looking for is having functions.php as a plugin. This makes it portable, regardless of the theme you are using. The most simple way is create a new file (something like my-woocommerce-functions.php) and start with the following: <?php /** * Plugin Name: My Custom WooCommerce Functions * Plugin URI: http://example.com … Read more

Define PHP variable from a seperate API if statement

Hi I’m the author of Multi Rating Pro. The simplest way to do this is to put this logic within the rating-result.php template file. You can call the API function passing in your own result_type and then check this in the template. if ( class_exists( ‘MRP_Multi_Rating_API’ ) ) { MRP_Multi_Rating_API::display_rating_result( array( ‘rating_item_ids’ => 1, ‘show_count’ … Read more

Where to put random functions?

wp-includes/functions.php is never a file you should modify. Any mention of adding something to functions.php is never referring to this file. Functions related to front-end display or theme behavior should go in your theme’s functions.php. If the theme may potentially be updated, then you should be using a Child Theme to add functionality, and they … Read more

wp_create_category deprecated?

You are most probably trying to use wp_create_category() on the front end, which will lead to the fatal error. wp_create_category() is not available on the front end, only backend. You should hook your function to at least admin_init where wp_create_category() is available. Just a note, looking at the source code, wp_create_category() uses category_exists() which is … Read more