Return HTML Template Page with PHP Function

Something I forgot in my previous comment was that shortcodes return content, both the suggested include and my alternative get_template_part will directly output the content (which is what you are seeing with the content appearing at the top of your page instead of where the shortcode is called). To counteract this we must use output … Read more

Increase number of posts in archive page

You can use pre_get_posts in your functions file to alter the query function wpsites_query( $query ) { if ( $query->is_archive() && $query->is_main_query() && !is_admin() ) { $query->set( ‘posts_per_page’, 100 ); } } add_action( ‘pre_get_posts’, ‘wpsites_query’ );

Change Custom Post Type slug

The register_post_type_args filter can be used to modify post type arguments: add_filter( ‘register_post_type_args’, ‘wpse247328_register_post_type_args’, 10, 2 ); function wpse247328_register_post_type_args( $args, $post_type ) { if ( ‘portfolio’ === $post_type ) { $args[‘rewrite’][‘slug’] = ‘stories’; } return $args; }

Get the first post term

I’m not sure what you mean by ‘first’ taxonomy… but, $terms = get_the_terms( $post->ID, ‘mytaxonomy’ ); returns an array of taxonomy term objects, so $term = array_pop($terms); Would give you the first term in the array. And then: echo ‘<a href=”‘.get_term_link($term->slug, ‘mytaxonomy’).'”>’.$term->name.'</a>,’ (You may want to include some if statements, in case an empty array … Read more

Can’t enqueue scripts in the footer?

Where did you put your code ? the “true” arguments goes in the wp_register_script();, not the wp_enqueue_script() ; the functions is: <?php wp_enqueue_script(‘handle’, ‘src’, ‘deps’, ‘ver’, ‘in_footer’); ?> meaning <?php wp_enqueue_script(‘NameMySccript’, ‘path/to/MyScript’, ‘dependencies_MyScript’, ‘VersionMyScript’, ‘InfooterTrueorFalse’); ?> E.G. <?php wp_enqueue_script(‘my_script’, WP_CONTENT_URL . ‘plugins/my_plugin/my_script.js’, array(‘jquery’, ‘another_script’), ‘1.0.0’, true); ?> does your theme have <?php wp_footer(); ?> at … Read more

Override get_template_directory() in child theme?

Late answer, but in WordPress 4.7 two new functions were introduced to address this question. get_theme_file_path() (for absolute file paths) and get_theme_file_uri() (for URLs) work just like get_template_part() in that they will automatically look in the child theme for that file first, then fallback to the parent theme. In your example, you could rewrite it … Read more

How many times can I hook into the same action?

WordPress hooks work like Hollywood: you don’t call them, they call you. But unlike Hollywood, they keep calling everyone on the list. It’s normal for an action or a filter to have multiple functions hooked to it, from different plugins, or even just different functions in the WordPress core that all do something specific. It … Read more