New answers tagged

0

If you are using child theme. Add filter in the functions.php of child theme like this. add_filter('get_the_archive_title','wpse_224884_filter_archive_title',10,1); function wpse_224884_filter_archive_title($title){ if ( is_category() ) { $title = sprintf( __( '%s', 'shaped-blog' ), single_cat_title( '', false ) ); } return $title; } Or ...


0

Assuming post type is my-post-type. We can create a page template with custom query using WP_Query. Let's say we create template-multier.php with the below code in the root directory of the active theme. <?php /* Template Name: Custom Post Type Archive */ //Custom header stuff here //Custom query for `my-post-type` $args = ...


1

This will display the title of the page when a static page is set to show posts. e.g. I show posts on my homepage... It'll do nothing. If I, say, show posts on page titled News... It'll show News in H1 This is used so that title of the page is shown, whenever posts are shown on a page but nothing when blog posts are shown on front page (home page). We ...


1

I am not sure about "popular", it doesn't seem so to me (but then I don't look at that many themes). You seem to grasp fine what each conditional does, so this shouldn't be confusing to you. This combines conditions to check that blog index is being displayed and it's not at the front page. Ah, the reason for single_post_title() I would guess is that it ...


0

why not like this? add_action( 'pre_get_posts', 'my_post_queries' ); function my_post_queries( $query ) { if ($query->is_main_query() && !is_admin()) { // maybe check for specific page here // if (is_tax('your-taxonomy') { $query = false; remove_all_actions ( '__after_loop'); // } } } Or did I ...


0

This has happened two times for me. At the first time I changed the encoding of the file (header.php I think) to UTF-8 without BOM and all templates disappeared. Changed it back to regular utf-8. At the second time I somehow edited/renamed the index.php (/themes/theme_name/index.php). Just had to create an empty index.php and now everything seems to be ok. ...


0

I think you might not need multiple loops to get your data into your template. As I understood it, it’s a matter of sorting. You want to sort your posts so that posts with premium-franchisor set to 1 appear first. You can already do this using WP_Query. This is how your arguments array could look like: $args = array( // Get all posts ...


0

You cannot have a rewrite slug of '/'. Note that using a slug of '', which you will find floating around, will not work for the latest WordPress versions either. If you want a url like http://domain.com/custom-post, there are no bullet-proof solutions, but the answer to this question will give you some leads: Remove slug from custom post type post URLs


5

If I am understanding you have a taxonomy that is shared across multiple post types? And you want to make a custom template for each post type using the Wordpress's templating system. Which isn't possible. What you could do is add conditionals to your taxonomy-disrupt-categories.php to check what the current post type is and load different template parts ...


0

They do not differ technically. These files exist in your theme directory and the template that loads is determined by the following: If you have a product with slug of dmc-12, then WordPress will first look for a file called single-product-dmc-12.php in the theme directory. If it finds it it will use that template when creating the page. If this file does ...


1

You need to create attachment.php in your child theme. Please check here for more details.


0

One simple way of doing it is by using a php function called "basename". If you have 2 header headerone.php, headertwo.php you can load different resources depending upon the name of the page you are viewing. <!DOCTYPE html> <html> <head> <meta charset="utf-8"/> <?php if(basename($_SERVER['PHP_SELF']) == ...


0

If you want to stick with your enqueued files (probably a good idea as outlined here), then - yes - you could add some conditionals in your functions.php such as: if(some conditional) { // enqueue header.php style here } if(some other conditional) { // enqueue header-full.php style here } Or, you don't have to enqueue them at all. You could just ...


0

Enqueue style depending on a template filename: if('header.php' == basename( get_page_template() ) { // check the template file name // enqueue header.php style here } if('header-full.php' == basename( get_page_template() ) { // check the template file name // enqueue header-full.php style here } wp_enqueue_style already registers a style so you ...


6

Include CSS and JavaScipt in the functions.php. Create an empty PHP file, call it header.php, and yes wp_head() goes just before </head> not before <body> tag. <!DOCTYPE html> <html> <head> <title>Website</title> <link href="style.css" rel="stylesheet" type="text/css" /> <?php wp_head(); ?> ...


0

While not directly an answer to the question at hand, it should probably also be noted here that by default WordPress adds a class name to the <body> tag for custom page templates. So for instance, if you are viewing a page that has a custom page template, and the template's filename is custom.php, then a class name of page-template-custom will be ...


2

Don't include CSS and JavaScript manually, there are special functions for this purpose. Modify this code to meet your requirements and put it to the functions.php of your theme. <?php $template_file_name = basename( get_page_template() ); // get template file name if('my_template.php' == $template_file_name) { // check file name wp_enqueue_style( ...



Top 50 recent answers are included