New answers tagged

0

This piece of code work for me <? php /** * Add panel | custom section and settings */ function firstest_news_theme_customize_register( $wp_customize ) { // add panel // Add Theme Options Panel. $wp_customize->add_panel( 'theme_option_panel', array( 'title' => esc_html__( 'Theme ...


1

EDIT: Original answer was inaccurate as you can do this with wp_update_post and the meta_input field As per the updated question and comments this is possible with wp_update_post (or wp_insert_post for a new record) using the meta_input key on the array, e.g.: $metaValues = array( 'key1' => 'value1', 'key2' => 'value2', // ... as many ...


-1

Please try below code : <?php get_header(); ?> <main role="main"> <section class="container"> <div class="row"> <div class="col-lg-8"> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> <h1 class="...


0

I would suggest looking into the ways that the various units function. There would rarely be a case where you would use one unit exclusively. I generally use ems, rems, and %. This article may help get you started: understanding and using rem units in css


1

Your question specifically asks if wp_is_mobile() is effective; not how device detection should be evaluated. The function just works. So Yes, it is effective. As an example when it may be preferred to client-side detection, even Mozilla thinks that's a bad idea. It's worth re-iterating: it's very rarely a good idea to use user agent sniffing. You can ...


2

One problem (there may be more ;-) is that $post->ID is probably out of scope when you call it from the page template. You could change the way the function works to take the post ID as a parameter, like this: function my_related_artickes($postID) { $categories = wp_get_post_categories( $postID ); $ids = array(); foreach( $categories as $cat )...


1

Is there anything special for dealing with $_POST in this case? Maybe, if you can elaborate more on what you mean by "special"? But as with other PHP arrays, you should always check if the POST variable is actually set before attempting to use it: // Example for the Edit_Email_1 input: if ( isset( $_POST['Edit_Email_1'] ) ) { return $_POST['...


0

One option is to pass the post ID as a url parameter when the edit link is clicked. For example, in some template user can see a list of one's posts. Each post has an edit link and the post id appended to the link as a url parameter. <ul> <?php foreach( $users_posts as $users_post ) : ?> <li> <span><?php ...


1

I know this comes a bit late but I going to leave it in case some one needs a different alternative from the above anwser. We add the function below to our theme most probably under functions.php or any other included file. The function below wraps the oembed inside the video-container div and below function is the respective CSS for the new class /** * Add ...


0

You have missed "echo". Use the code below. Should work. <span class="<?php echo get_theme_mod('features_one_icon' ,'fa fa-bullseye');?>"> </span>


0

The problem was here: <input type="file" id="_themename-advert-create-image" name="_themename-advert-create-image" /> It should be: <input type="file" id="_themename-advert-create-image" name="_themename-advert-create-image[]" /> Still can't understand why I should add [] in my name, ...


0

Since 4.7 get_theme_file_path() is the right function to use: require_once get_theme_file_path( 'gateway/config.php' );


0

You can use either require_once(get_stylesheet_directory() . '/gateway/config.php'); or (should be faster) require_once(__DIR__ . '/gateway/config.php');


1

I was able to resolve this after I slept on it & I looked at the part of the customizer code that I hadn't included, which is the section portion of all things. All it needed was an esc_attr on it as shown below. Initial version: // Header Footer Code Section $wp_customize->add_section( 'header_footer_code', array( 'title' =&...


2

This is probably not the best answer, someone may know a way for this input to be properly handled given that you want to store code in it, but this will probably do what you're intending: <?php echo html_entity_decode(get_theme_mod( 'footer_code')); ?> Note this is probably somewhat of a security risk, and this behaviour of Wordpress escaping the ...


0

Yes, you just have to call the function the_excerpt(): Right after … <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a> … you add: <div class="search-excerpt"><?php the_excerpt(); ?></div> And then you can style it in your CSS file with: .search-excerpt { /* some code */ }


0

function my_custom_css() { $upload_dir = wp_upload_dir(); $base_dir = wp_get_upload_dir(); $styles = wp_get_custom_css(); if ( $styles || is_customize_preview() ) : $type_attr = current_theme_supports( 'html5', 'style' ) ? '' : ' type="text/css"'; $file = file_put_contents($upload_dir['basedir']."/new-style-...


0

This filter removes the CSS and hides the adminbar on the entire site: function hide_admin_bar_from_front_end(){ remove_action( 'wp_head', '_admin_bar_bump_cb' ); return false; } add_filter( 'show_admin_bar', 'hide_admin_bar_from_front_end' ); If you want to disable the CSS only, you must return true instead of false. If you need it conditionally: ...


1

get_next_posts_link() and get_previous_posts_link() are for linking between pages of a paginated post archive. For navigation between individual posts you want get_next_post_link() and get_previous_post_link(). Note the singular "post". function myslug_render_post_navigation(){ echo get_next_post_link( __( 'Previous post' ) ) . ' | ' . ...


1

Preface There's no WordPress-specific stuff in this answer, but I'm just trying to help since the official documentation is (as of writing) not very helpful.. But as I said in the comments, I don't use Elementor, which means I don't know much about Elementor's technical stuff. ( Even the non-technical ones, actually.. :) ) The $query needs a min/max and a ...


1

I noticed this error myself too when using the Elementor plugin. It is only displayed when WP_Debug is set to true. The location of the warning is wp-includes/post-template.php. This is not a theme location, so the short version is that you're not responsible for it. The error only appears when using Elementor. I think that the Elementor developers should ...


0

Your code is fine to me, except you made a mistake here: template_redirect('/product/channel-mcgilchrist'); WordPress does not have a function named template_redirect, only a hook with that name. So you should have used either wp_redirect() or wp_safe_redirect() which are valid functions to perform URL/page redirections in WordPress. wp_safe_redirect( '/...


2

Not sure what you're trying to do, but the problem you're having with this specific bit of code is that you're using the wrong function. You want get_the_post_thumbnail() instead. The function the_post_thumbnail() echoes the result of get_the_post_thumbnail(). $args = array( 'post_type' => 'post', 'orderby' => 'date', 'order' => 'DESC', ...


0

'posts_per_page' => 1, Do you really only want a single post to be returned? And what is the $parent value? Since you don't want anything but the post thumbnail, specify that you only need the post id(s). Try: $args = array( 'post_type' => 'post' , 'orderby' => 'date' , 'order' => 'DESC' , 'posts_per_page' => 1, ...


1

This is how I use this, to only occur when my theme is activated, and only if there is no pre-existing setting saved (to not break something done before my theme is used). /* * Set permlinks on theme activate */ function set_custom_permalinks() { $current_setting = get_option('permalink_structure'); // Abort if already saved to ...


1

Is functions.php in themes applied to all templates? The theme's functions.php is loaded on every request, yes. I imagine the functions of a theme acts like a controller for the pre/post filters/hooks? A theme's functions.php is just an entrypoint for a theme to run any PHP code it wants. You can see when in the loading sequence it's loaded here. It doesn'...


-2

get_header() is part of wordpress core. Seems your wordpress files damaged or installed incorrect. Try to reinstall it. Probably you should move D:\XAMPP\htdocs\wordpress into D:\XAMPP\htdocs\


1

Look into the theme template hierarchy. There is no "about.php" file and you should not link to any of the theme (PHP) files directly. Instead, you would create a theme file such as "page-about.php" and create its content in wp-admin as a Page with the slug "about," and WordPress will process that Editor content within the PHP ...


0

In order to rename you have to alter your code like bellow. You code was missing absolute path of the directory. That's why your code was not working. Adding ABSPATH will fix the code. rename( ABSPATH . "wp-content/uploads/Directory/Clients/$Client_Name", ABSPATH . "wp-content/uploads/Directory/Clients/$New_Name" ); Why not you use ...


2

You use the document_title_separator filter. So in your case: <?php function theme_prefix_filter_document_title_separator() { return '|'; } add_filter( 'document_title_separator', 'theme_prefix_filter_document_title_separator' ); ?>


Top 50 recent answers are included