How to create “page” used for generating PDF? [closed]

Since it’s a standalone script, you can just link to it directly and WordPress will be none the wiser. Just make sure you get the link right – if it’s in your theme, it will be something like: http://example.com/wp-content/themes/my-theme/generate-pdf.php Don’t hardcode the URL though, use the available template functions: <a href=”https://wordpress.stackexchange.com/questions/199196/<?php bloginfo(“template_url’ ) ?>/generate-pdf.php”>Generate!</a> Of … Read more

Changing code to remove 2 records for the first line

Here is how I got it to where I wanted it: Change $class = “span”.($k < 2 ? 6 : 12/(count($members)-2)); to $class = “span”.($k < 0 ? 6 : 12/(count($members)-2)); and remove this section completely: ($k === 2 ? ‘<div class=”clearboth”></div>’ : ”), I am sure there are other (better?) ways of getting to … Read more

Meta box not saving spaces

The answer is simple: do not use sanitize_html_class. Take the input as it is (you can still do basic validation like length, making sure it is an integer only etc) and if you need to output that on the front and you don’t trust the user who stored the data either use something like esc_html … Read more

How to get the first letter from custom field?

Try this…. <?php $string = get_field(‘first_name’); echo $string[0]; ?> I am not that much familiar with ACF. But my answer is based on their function reference here http://www.advancedcustomfields.com/resources/the_field/ Hope this helps. Sabbir H

Rearrange get_categories array compared to another array

Long story short, build a new array with the categories indexed by ID. Then you can just loop over the date-sorted IDs and do with them as you wish: $categories = get_categories(); $cats_index = $cats_dates = array(); foreach( $categories as $category ) { // Index the categories by their ID $cats_index[ $category->term_id ] = $category; … Read more

php if, else & custom fields – syntax error

There are a couple of ways to do it. Try: <?php if ( get_post_meta($post->ID, ‘author-photo’, ‘author-name’, ‘author-bio’, true) ) { ?> <div class=”authorbox”> <div class=”authorphoto”> <img src=”https://wordpress.stackexchange.com/questions/200118/<?php $key=”author-photo”; echo get_post_meta($post->ID, $key, true); ?>” /> </div> <div class=”authorbox-content”> <h3 class=”author-name”><?php $key=”author-name”; echo get_post_meta($post->ID, $key, true); ?></h3> <p><?php $key=”author-bio”; echo get_post_meta($post->ID, $key, true); ?></p> </div> </div> <?php … Read more

How can I remove these resize lines from the comment box?

he following CSS rule disables resizing behavior for textarea elements: textarea { resize: none; } To disable it for some (but not all) textareas, there are a couple of options. To disable a specific textarea with the name attribute set to foo (i.e., ): textarea[name=foo] { resize: none; } Or, using an id attribute (i.e., … Read more

How I can add div to menu?

When using wp_nav_menu you can pass arguments to it which help you style the output, look at: $container Whether to wrap the ul, and what to wrap it with. Allowed tags are div and nav. Use false for no container e.g. container => false . $container_class the class that is applied to the container. $container_id … Read more

Custom user roles doesn’t apply changes

in WP documentation: NB: This setting is saved to the database (in table wp_options, field wp_user_roles), so it might be better to run this on theme/plugin activation It means that when you first run your code it is saved to db, and if you try to do it one more time it will not be … Read more