Tag Info

New answers tagged

1

I wouldn't use custom page templates merely for changing the layout of the blog posts index. Using page templates for the blog posts index bypasses the core handling for display of the blog posts index (which per the template hierarchy uses either home.php or index.php to render). Edit I never...said that I want to change layout of the blog posts ...


3

You haven't created a query to return your post index results. Let me back up... In WordPress something called the "Main" query runs very early in the page load, and well before your template files load. That query retrieves the posts to display and also (more or less) determines which template file to use to display the results. That "Main" query ...


3

This is an add on to @kaiser answer, read that before. To be honest wp_localize_script, add_action are the best part of Ajax API, and really, they are an help, not a problem. Let's imagine you have 120 ajax functions. Even if you don't use admin-ajax.php see again your workflow: Check user is authenticated, if not, return a 403 header and exit(); ...


5

Custom implementation vs. Standard API usage Using the WP AJAX API is the way to go. First off, you get access to the complete set of WP APIs, you can leverage standard jQuery $.ajax() and similar API calls and you are running standard conform, gaining access to all knowledge spread around the web with articles or for e.g. in answers on this site. In the ...


3

Yes, this is the intended behaviour: page-{slug}.php - If the page slug is recent-news, WordPress will look to use page-recent-news.php So, simply use a different filename for your templates, like template-contact.php for example. You can find more info about this here: https://codex.wordpress.org/Template_Hierarchy


0

I'm not entirely certain, but I think you are looking to use this plugin or one like it. http://wordpress.org/plugins/easy-digital-downloads/ You should be able to create free download pages for no cost to your users. Another option would be to just use a second page. In post option "Download Link" box, put the link of another WP page that you would ...


3

If you have a look at the template hierarchy, custom post types are usually displayed on archive templates. Normal template hierarchy does not make provision for page.php type templates to be used to display custom post types by default. The problem with archive templates is that they don't automatically get added to the default nav menu, and creating a ...


2

You forgot to end the if statement. this should work: <div id="primary" class="site-content"> <div id="content" role="main"> <?php while ( have_posts() ) : the_post(); ?> <?php get_template_part( 'content', 'page' ); ?> <?php if (is_user_logged_in()): echo '<form ...


2

You are missing an <?php endif; ?> [...] else: echo 'Sorry, only registered users can view this information'; endif; <?php endwhile; // end of the loop. ?> [...]


0

If I understand correctly, the book and the reviews share same taxonomy. Then is just a matter of get the taxonomy term for the book in the single-books.php, save it in a variable and then run a query using that variable for the 'tax_query': if ( have_posts() ) { the_post(); // get the term for the current book and save in a variable $book_terms = ...


0

You can use the template_include filter to load a template file from your theme: add_filter( 'template_include', 'my_page_template', 99 ); function my_page_template( $template ) { if ( isset( $_GET['info'] ) && $_GET['info'] == 'some_value' ) { $new_template = locate_template( array('my-template.php' ) ); if ( '' != ...


0

Yes you can. You can create a page template to use and in that use the following: if (isset($_GET['info'])) { echo $_GET['info'] } Copy your default page template and creating a new one based on that. Make sure you change the value of the 'Template Name: XXXXX' also. The template should use the get_header and get_footer commands above/below your new ...


1

You can certainly set up a page template for custom post types. Give this a whirl: <?php /* Template Name: Your template name */ // Get header get_header(); ?> <div id="primary"> <?php // Query post type $the_query = new WP_Query( array( 'post_type' => 'cpt_name', 'posts_per_page' => -1 ) ); if ( $the_query->have_posts() ) : ?> ...


3

WooCommerce questions are off-topic, but since reviews are merely comments, I think we can make the case that ordering comments is still on-topic. wp_list_comments() has a reverse_top_level parameter that will set the most recent comment first and then go backwards. Assuming it works like I think it should then you'd want to add this parameter to ...


2

You mean class-IRC.php or class-IXR.php? Just include the files before you call IXR_Client. I use such code to call IXR_CLIENT and it worked on my site: include_once( ABSPATH . WPINC . '/class-IXR.php' ); include_once( ABSPATH . WPINC . '/class-wp-http-ixr-client.php' ); $client = new WP_HTTP_IXR_CLIENT( 'http://othersite.com/xmlrpc.php' );


3

There's a new filter in WP core (3.9) to remove page templates. It can be used from child themes. https://core.trac.wordpress.org/changeset/27297


1

The correct way is latter one - correctly configure your CPT registration to have post type archive and use appropriate template file for it. However it gets tricker with your additional requirements. Exposing post type archives to be used in menus is significantly requested/explored topic, but I don't think it made it into core yet. There are mutiple ...


2

You did call the header twice in your page-static.php. You can remove the second call (before the_post()). If you remove the second call of the_header(), the Stylesheet should not be delivered anymore. <?php /* Template Name: Static Page */ ?> <?php wp_dequeue_style( 'style' ); ?> <?php get_header('custom'); ?> <?php ...



Top 50 recent answers are included