Tag Info

New answers tagged

1

For temporary preview/theme switch (while visitor still see the default theme), then you can use plugins: http://wordpress.stackexchange.com/a/161196/42702


0

I have to say it's unusual to see someone using a custom template for a blog considering the index.php is for this; I guess it depends on your set up. I'd suggest being careful whenever doing custom queries.


0

I believe I have come up with a temporary solution from random miscellaneous sources online. I would love for someone to expand on my answer to make it more "bullet proof" so to speak. However, in the short run, this solution does work. Hook into the current rewrite rules. add_action('rewrite_rules_array', array($this, 'rewrite_rules_array'), 100); ...


1

That is expected and how Template Hierarchy works. I know there was a track ticket raised a couple of years ago regarding this issue if to an index for archives should be introduced in core or not. (EDIT: Found the ticket, check it out here: Ticket #13816 There should be built-in index pages for taxonomies) That idea was scrapped and will never see light in ...


1

Use this code in your functions file for a child theme and change the 8 to the post i.D you want to use the custom single CPT template on. function get_custom_post_type_template($single_template) { global $post; if ( is_single('8') ) { $single_template = get_stylesheet_directory() . '/custom-cpt-template.php'; } return ...


0

Well, for me the problem, was including during the post content it would not work, but if i did included in the top of the page template model i created, then it would work if i used something like this: VALID FOR PHP 5.3+ $array=array("keywords"=>"keywords here","description"=>"desc here"); add_action( 'wp_head', function() use ( $array ) { ...


4

For the templates WordPress uses, please always refer to Template hierarchy scheme in the Codex. As you can see there, single-{$posttype}-{$slug}.php does not exist, there is only single-{$posttype}.php. To do what you want, have a look at the filter 'single_template': add_filter( 'single_template', function( $template ) { global $post; if ( ...


0

Same pages as answer above "5 and 9" can also be hidden/removed from backend with PHP: function hidepages_php( $query ) { if( !is_admin() ) return $query; global $pagenow; if( 'edit.php' == $pagenow && ( get_query_var('post_type') && 'page' == get_query_var('post_type') ) ) ...


0

Remove .even & .odd class styles from style.css and use CSS psudo classes. .comment:nth-child(2n) { your styles for even } .comment:nth-child(2n+1) { your styles for odd }


0

I guess you can make a page template and add the following code in that:- <?php $args = array( 'post_type' => 'your_custom_post', 'posts_per_page' => 10 ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); the_title(); echo '<div class="entry-content">'; the_content(); echo '</div>'; ...


0

I think that Brad's answer point in the right direction if I understand you correctly. I really do think that you need to rethink your use of templates. Using archive.php to act as a template for all the other archive types cramps one style quite a lot. It is just easier to create all these archive type templates and create the opportunity for a wider use ...


2

add_filter( 'template_include', 'wpsites_cpt_archive_page_template', 99 ); function wpsites_cpt_archive_page_template( $template ) { if ( is_post_type_archive() ) { $new_template = locate_template( array( 'your-cpt-template.php' ) ); if ( '' != $new_template ) { return $new_template ; } } return $template; ...


1

From the info you have given in your post, I believe you are using a custom page.php template here Here is the the reasons you get the output as stated: The main query executes on each and every page that is loaded. The main query is very specific for every type of template. $wp_query is the super global used by the main query To test the how unique the ...


1

Because the global $wp_query represents the query for the current page (the "main" query) and is completely separate from your custom $author_query. If you want to use pagination functions, you can "fake it" by temporarily setting $wp_query to your custom query, and then resetting afterwards: global $wp_query, $wp_the_query; $wp_query = $author_query; // ...


1

Here is the query format for displaying author posts with pagination. You will have to also add paged argument to paginate. <?php // fix pagination issue if ( get_query_var('paged') ) { $paged = get_query_var('paged'); } elseif ( get_query_var('page') ) { $paged = get_query_var('page'); } else { $paged = 1; } $args = array( ...


2

Let's address possibility for starters. There are two parts to front end output in WordPress: Theme template system, which is pretty flexible and relatively easy to adjust, although mostly PHP-centric Template tags (and related) functions, which are extremely PHP–centric and vary wildly as to how easy they are to adjust So implementing templating engine ...


1

Of course it is possible: https://wordpress.org/plugins/smarty-for-wordpress/ If it is a good idea that depends on your skills. If you are more comfortable with smarty, then use it. I see no reason why not.


0

Use the hook template_redirect instead - this will ensure it only runs on the front-end of your site, and not for the admin, login, registration or signup pages. function wpse_159552_maintenance() { if ( ! is_front_page() ) { wp_redirect( home_url() ); exit; } include 'maintenance/index.html'; exit; } add_action( ...


1

Try this - I've not implemented it fully, but I have tested it and it seems to work. Place it in your functions.php and call <?php list_child_pages(); ?> in your template or use the shortcode [childpages] in your editor. <?php // List Child pages of a parent. function list_child_pages() { global $post; if ( is_page() && ...


0

You have it right @Hassan Alvi, you should use get_template_part() for each stage of your one pager. Dont use id use specific class instead, it's more object oriented. It will make you code a lot more readable and more easy to maintain!


2

Before I start, I would recommend that you read: Creating a Static Front Page OK, when you select a static front page, one of the following templates are used to display the front page front-page.php page.php any other custom page template This is the part that you already have working from what I can understand from your question Now, the blog page. ...


5

This doesn't work the way you think it does because get_pages doesn't do what you think it does. First, understand that all pages, all content, in WordPress is really a "post". A "Page" is just a special type of post. Now, in a normal environment, you wouldn't call "get_" anything. This is why you're confused, because you're directly getting things and ...


-1

Without seeing your front-page.php file, here is what I'd suggest if you're using a posts page of "Blog". Create a custom page template for your Blog page. This is done the same way as front-page.php except for 2 things... You'll need to put the following comment at the top of your blog.php file (if that's what you're gonna call it. /* Template Name: ...


0

You might want to check out this post, as your post is linked to that question. That should explain most of your question. As for your code, move that outside the the loop. You were nearly there with your code. Check out get_terms in the codex to see which objects you can use that is returned by the function. You can use $term->description instead of ...


1

Unfortunately all of your code is wrong. What you are doing is the same as query_posts, which should never be used. Also, never swap the main query on any type of archive page or on the home page for a custom query To create a tag page, just simply make a copy of your index.php, and rename it tag.php. Here is a copy of the bundled theme, twentyfourteen's ...



Top 50 recent answers are included