New answers tagged

1

You can just run through the loop and set a flag: if ( $query->have_posts() ) : $any_in_cat = false; while ( $query->have_posts() ) : $query->the_post(); if ( in_category( 'first-major' ) ) : $any_in_cat = true; endif; endwhile; $query->rewind_posts(); /* if $any_in_cat == true at this point then ...


1

You can create a separate function to check your array of posts contains a post with that category. It will basically do what you are now but it will allow you to call the function once instead of each time through the loop. You would put this code in your functions.php file: function does_array_contain_category( $categories, $posts ){ foreach( $posts ...


-2

is_category() tests to see if you are displaying a category archive, but you are displaying a single post, so this will always return false in_category() tests to see if a given post has a category in that specific category and must be used in The Loop, but you are trying to figure out what the category is, before you get to the loop. if ( is_single() ) {...


2

The admin-init hook only fires on admin screens. The correct hook to use for registering post types is init. So change: add_action( 'admin_init', 'smoelenboek' ); ... to ... add_action( 'init', 'smoelenboek' ); ... and flush your rewrite rules once (save permalink settings in admin) and all should be well.


1

Remove the read more with this code in your functions.php: function wpse_230169_excerpt_more($more) { return ''; } add_filter('excerpt_more', 'wpse_230169_excerpt_more'); Then in your template file just add the link wherever you want with: <a href="<?php the_permalink(); ?>">Read More</a>


1

To expand your conditional to check for display of one of your terms, you can do this: if ( is_page() ) { the_title(); } elseif ( is_tag() ) { single_tag_title(); } elseif ( is_tax( 'mtags' ); ) { single_term_title('More Tags: '); } However, if you use your theme's custom taxonomy template for this taxonomy, taxonomy-mtags.php, then you can ...


1

You could try a plugin like Visual Editor Custom Buttons. Or you may want to do something custom. There's a solid example at http://code.tutsplus.com/tutorials/guide-to-creating-your-own-wordpress-editor-buttons--wp-30182.


0

Solved. Problem was in copying theme's css file from an old to a new site. The "fa" icons changed from a graphical to a textual form in the css style. Thanks for help.


0

Check following thing into your site Please check that Font Awesome CSS is loading into page , you can check it using view page source, also need to check fonts folder is uploaded into all your sites , if you not upload fonts folder then it don't display icon.


0

By default WP support 3 image sizes ie Thumbnail, Medium and Large. If you want to remove any of these then you can use a filter "intermediate_image_sizes_advanced" to remove the default image sizes. function wp_remove_default_image_sizes( $sizes ) { unset( $sizes['thumbnail'] ); // remove thumbnail support unset( $sizes['medium'] ); // remove ...


2

This should add the drop class to all the li elements in the menu and also add your classes to the wrapping ul: function wpse_232637_add_menu_parent_class( $items ) { foreach ( $items as $item ) { $item->classes[] = 'drop'; } return $items; } add_filter( 'wp_nav_menu_objects', 'wp_232637_add_menu_parent_class' ); $args = ...


3

From quick look WP seems to process array of theme data in a way that is used for both PHP and JS sides. Result passes through wp_prepare_themes_for_js filter, which seems like a suitable place to override screenshot URL as necessary. This worked in my dev install: add_filter( 'wp_prepare_themes_for_js', function ( $themes ) { $themes['r-test']['...


0

Depending on your setup you could use the conditional is_home() or is_front_page() like this: <?PHP if( is_home() ) { ?> <div> … </div> <?PHP } ?> See also the question "When to use is_home() vs is_front_page()?" for further details on the defferences between the two…  PS: you should consider using a child theme for this.


0

Why don't you create a shortcode for this , it's much easier, standard and flexible.


0

Short answer: most probably there is. I would recommend you use a child theme to achieve this. You can then copy any of the parent theme's templates into your child theme and alter them as you like. In your case it's probably something like "single-portfolio.php" inside the templates folder of the theme. A good starting point for working with child themes ...


0

For getting the child term of an parent you can use get_terms function Here you can provide hide_empty as false ( this will list all term ) parent as the parent term id ( this will return the term related to that parent id $tax_id = $term->term_id; $terms = get_terms( 'post_tag', array( 'hide_empty' => false, 'parent' => $tax_id, ) );...


2

I think you have a misunderstanding what the homepage (index page) is in WordPress context. The homepage is the main page of the site, by default, this will be like example.com, AND any paged page derived from this homepage. So example.com/page/2 is also regarded as the homepage. In short, any page where is_home() returns true will be a home page. By ...


0

May be you need this theme... Try it out it's a free theme and same as per your requirement. It's a one page website theme available on wordpress.org. https://wordpress.org/themes/one-page/ Check out the demo here https://wp-themes.com/one-page/


0

Unless you have generated metafields called 'home', 'about', 'contact' and 'services' in functions.php using add_post_meta your calls to get_post_meta will always return false. So if you test if they are true later on, the answer is 'no' and nothing will be displayed.


2

Embarrassing. $(mediaUploader).on('select', function(){ Should be: mediaUploader.on('select', function(){ In case anybody stumbles upon this, $({item}) looks for the item in the DOM, not the variable of the same name in the previous code. Since the select event isn't firing in the DOM, the callback function isn't going to fire either.


1

I solved using this filter: add_filter( 'get_custom_logo', 'custom_logo_url' ); function custom_logo_url ( $html ) { $custom_logo_id = get_theme_mod( 'custom_logo' ); $url = network_site_url(); $html = sprintf( '<a href="%1$s" class="custom-logo-link" rel="home" itemprop="url">%2$s</a>', esc_url( $url ), ...


0

You could put files in wordpress/wp-content/themes and then include them from various themes. You could even make a folder named wordpress/wp-content/themes/global-includes or shared. For me, including a file from the parent directory I couldn't just do: <?php include_once "../globalform.php"; ?> Instead I needed to do: <?php include_once ...


-1

It's probably best to render the shortcode on output by running it through do_shortcode()


0

First, use a different id for your panel than panel_id. Your sections will not show up without associated controls and settings, and panels will not show up without associated sections. Try adding controls to each section and that should fix your issue.


0

What you should do is first make sure you're using a Child Theme: https://codex.wordpress.org/Child_Themes Then you should be able to copy over the template file being used in the parent theme, to your child theme's directory, and customize from the child theme directory as you want. WordPress should automatically load the file from your child theme if it ...


1

Well, I found not an answer, but a workaround for this question. In the_mx_limited_gallery function, I added a negated is_single check around most of the contents of the function, so basically the limited posts and custom code show only if you are on a page other than a single post. This isn't how I originally intended, but it works for the time being. ...


0

<? // Check: // 1. If you are editing post, CPT, or page // 2. If post type IS NOT SET if( 'post.php' == basename($_SERVER['REQUEST_URI'], '?' . $_SERVER['QUERY_STRING']) && !isset($_GET['post_type']) ) { // get post ID $postid = $_GET['post']; // check the template file name if ('my_template.php' == get_page_template_slug($...


0

"available only when user choose this template" ? I'm not sure (I doubt it) if this is even possible. Instead I would suggest either of the following two options: If you want to make the page template configurable on a per-page basis then meta boxes could be the right direction. You could for example add an option like "use featured image as background" or ...


0

Here's an example of a solution I configured, which leaves the site in the network, but establishes a domain map from any registered domain, to the network. It makes the network site appear to be a completely independent site, with all the functionality (log-in, etc.) intact. Goal: Map client's registered domain, both www.foosite.com and foosite.com over ...


0

As @N00b said, if a selector matches between bootstrap and wordpress, and is more specific, then it will overwrite and you'll see the changes.


2

This can become a quite an expensive operation which can seriously damage page load time. At this stage, your code is quite expensive. Lets look a better way to tackle this issue. What we need to do is to minimize the time spend in db, and to do this, we will only get the info we need, that is the post_author property of the post object. As we now, there is ...


4

Child themes are not the only way to extend a theme, not even the best. Many themes offer hooks: actions and filters. You can use these to change the output per plugin. Let’s say you have a theme named Acme, and its index.php contains the following code: get_header(); do_action( 'acme.loop.before', 'index' ); ?> <div id="container"> &...


0

<?php if( is_category() ) { global $wp_query; $term_obj = $wp_query->get_queried_object(); $author_array = array(); $args = array( 'posts_per_page' => -1, 'category' => $term_obj->term_id, 'orderby' => 'author', 'order' => 'ASC' ); // Get the posts in the ...


1

For me the rule of thumb is am I extending/revising an existing theme? If so I'll want to be able to update the theme (assuming it's well supported) without nuking all my changes. You can read more here in the codex. If I'm creating something custom I find it best to just use my own starter theme (or something like Underscores) and edit the theme itself.


0

The full solution that works for me without modifying the Wordpress core is to clone the human_time_diff() function and place it inside functions.php as a renamed human_time_diff_chinese(), then swap all occurrence of human_time_diff() function with this new human_time_diff_chinese() function. function human_time_diff_chinese( $from, $to = '' ) { if ( ...


4

I ran your filter in my development area. It didn't work. Then I switched off the Yoast SEO plugin, which I knew was also messing with the page title. Then it worked. So my suggestion would be it is another plugin that is messing with it. In the case of Yoast, it was a filter call to pre_get_document_title that returned non empty. In that case ...


1

If you check out the source of human_time_diff: if ( $diff < HOUR_IN_SECONDS ) { $mins = round( $diff / MINUTE_IN_SECONDS ); if ( $mins <= 1 ) $mins = 1; /* translators: min=minute */ $since = sprintf( _n( '%s min', '%s mins', $mins ), $mins ); } elseif ( $diff < DAY_IN_SECONDS && $diff >= HOUR_IN_SECONDS ) { $...


3

After some experimenting I came to the following suggestion: could it be, that the <title> tag is "hard coded" inside your parent theme's header.php? If that is the case, you could try to remove the <title> tag from your child theme's header.php (copy your parent's header.php into your child theme folder) and then add the theme support back ...


0

You can try to alter the $attributes string, since that outputs the attributes in the a tag. The following is untested: $myClass = 'some-custom-class'; $myClassAdded = false; $attributes = ''; foreach ( $atts as $attr => $value ) { if ( ! empty( $value ) ) { $value = ( 'href' === $attr ) ? esc_url( $value ) : esc_attr( $value ); if( $...


0

You need to add the paged parameter to your WPQuery: $paged = ( get_query_var('paged') ) ? get_query_var('paged') : 1; $query = new WP_Query( array( 'posts_per_page' => 5, 'paged' => $paged ) ); Here are the docs.


3

Having read your post from top to botom and bottom to top, you have in all probabilty a filter that is passing a title through the pre_get_document_title filter. The clue here the following statement: I've also tried pre_get_document_title, which does fire on page load, Looking at the soure code for wp_get_document_title(), we see the following code: ...


1

There are many differences in css files of both websites. For example, have a look at the div having class et-top-navigation by inspecting it in browser. You will find that in staging website, there is top padding and left padding applied while it is not in case of live website. Similarly check for other css changes in staging website or simply take backup ...


2

If the parent theme does not declare support for title-tag you can do it like this in child theme /** * Theme support should be added on `after_setup_theme` */ function add_theme_support_child() { add_theme_support( 'title-tag' ); } add_action( 'after_setup_theme', 'add_theme_support_child', 11 ); Filter document_title_parts expected return type ...


0

Add bellow code in your functions.php file. } add_filter('comment_form_default_fields','remove_comment_fields'); function remove_comment_fields($fields) { unset($fields['url']); return $fields; } add_filter('comment_form_default_fields','remove_comment_fields'); Refference url


0

You can use TGM Plugin Activation library to let the user know about required and recommended plguins that your theme depends on. Automatically installing plugins is not a better choice instead let the users know that X plugin should be installed and activated in order for the theme to work properly. If your theme requires a plugin without which it gives ...



Top 50 recent answers are included