Tag Info

Hot answers tagged

4

Before starting answer I have to say that regarding this topic css and js are not the same. The reason is simple: while adding js to the body of the page (in footer) is a common and valid way to go, css need to be placed in the <head> section of the page: even if majority of browsers can proper render css in page body, that's not valid HTML code. ...


3

You have a lot of PHP tag spam, e.g.: ?><?php This is bad, confusing, makes your code difficult to read, and a waste of your time to type. It's the difficulty reading your code that has lead to your problem, including the lack of indentation. These are important, and any good editor will do them for you effortlessly. If we remove the PHP tag spam, ...


2

I think the best way here would be to run three separate loops here (you can also do two loops, but then you need to get full posts in the men and women queries, combine them and shuffle them), the first two will be used to get 5 men and the second loop will get 2 women. You can adjust this as necessary. The third loop will use the info from the first two ...


2

I made a few adjustments. Once I created my two arrays, I combined them this way $merged_queries->posts = array_merge( $women->posts, $men->posts ); shuffle($merged_queries->posts); $merged_queries->post_count = $women->post_count + $men->post_count; while ( $merged_queries->have_posts() ) { $merged_queries->the_post(); // do ...


2

I am not calling it inside of a hook but just straight away as the first thing in a MU plugin. At that point all the info you are requesting won't be available. That's running before any hook and before WP is fully loaded. Use a hook like wp_loaded, admin_init, after_setup_theme ... whatever serves your purpose best.


2

Write it out in english and be clear about your logic, aka if you say that X should happen when Y is true, what happens if Y is false? AKA else. If X then Y, else Z If we're on the home page, then do nothing otherwise if the page has a thumbnail then run code that pops the page title on top of full width thumbnail with suitable CSS ...


2

You should wrap your enqueue/register function in your conditional, not your add_action() You can try something like this using the is_404() conditional check function enqueue_404_script() { if(is_404()) { //do what you need to do } } add_action( 'wp_enqueue_scripts', 'enqueue_404_script' );


1

If I understood you correctly: <?php //if home, do nothing if( ! is_home() || ! front_page() ) { //if has post thumbnail if( has_post_thumbnail() ) { the_post_thumbnail( 'full' ); echo '<h1 class="entry-title">'. get_the_title() .'</h1>'; } else { //no post thumbnail, show normal entry ...


1

Before I start, I must say that your terminology is quite confusing and plain wrong. You should take your time and read through my answer to this question: Is There a Difference Between Taxonomies and Categories? As I stated before, there is no in_term() function to check if a post has a specific term. There is however a has_term() function which accepts ...


1

Its not identical to Drupal Views, but i think WP Views is the closest you will get to Drupal Views. I am a Drupal guy, and i use WP Views for every Wordpress project i create.


1

Since you've designated a specific page to be your Post Archive ( blog ) it no longer is a standard page; meaning is_page() will likely fail. Since your blog page is now more of an archive, it is automatically being returned because of your first conditional. is_singular() - Returns true when viewing a single page, post, or post type. So what you're ...


1

In a template file, this should do it: <php If (!is_user_logged_in()) { wp_redirect( "start/login" ); exit(); } ?>


1

The reason why your check didn’t work is because is_singular() checks for post types, not for post IDs. is_singular( 'product' ) checks if the current post is of the type product, nothing else. The comparison 2295 === get_the_ID() does exactly what you need.


1

I'd encourage you to take one step further back and avoid using URLs to determine theme at all. (And FYI, what you're describing are subfolders, not subdomains which would be red.example.com.) The reason not to do this is to avoid duplicate content issues with search engines. Technically, you could work around them, but it can also be confusing to visitors ...



Only top voted, non community-wiki answers of a minimum length are eligible