Template tags to display custom post type posts in category template?

Custom post types are by default excluded from the main query except on taxonomy pages and custom post type archives. You can simply use pre_get_posts to correctly alter the main query (alter the query variables before the SQL query is build and executed) to your needs. Just a few notes on pre_get_posts pre_get_posts runs front … Read more

How to load different CSS in different Header?

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 don’t need to register a … Read more

Creating a custom category page with pagination

You have a few issues here The following piece of code is wrong and unnecessary $category = get_post(); $category = $category->post_title; The current page object is saved in get_queried_object(), so you can use this function to get your post title. Also, post_title is not the correct property to use here. You want to look at … Read more

On this day PHP code

Adapted from the Codex, tweaking WP_Query to get all years before this. Untested, but should work. $on_this_day = array( // remove the year from the first query array ‘monthnum’ => date(‘n’), ‘day’ => date(‘j’); ); // Create a new filtering function that will add our where clause to the query function filter_where( $where=”” ) { … Read more

How to Handle CSS for Multiple Header header.php Files?

That’s not how you use get_theme_file_uri(); You need to specify the directory RELATIVE to your currently active theme’s directory. So for example, if your currently activated theme is rm-acf1, and all of your custom header CSS files are located in the subfolder hdr-styles. This is your theme directory: ./wp-content/rm-acf1/ This is your header styles directory: … Read more

How do I set a specific template for sub-categories?

I would recommend using the category_template filter – just check if the current category is an ancestor of 67: function wpse_179617_category_template( $template ) { if ( cat_is_ancestor_of( 67, get_queried_object_id() /* The current category ID */ ) ) $template = locate_template( ‘category-slider.php’ ); return $template; } add_filter( ‘category_template’, ‘wpse_179617_category_template’ );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)