New answers tagged

0

i solved with this code placed in functions.php function my_admin_notice(){ echo '<div class="updated"> <p>message here!</p> </div>'; } add_action('admin_notices', 'my_admin_notice');


1

If you look at the source of _wp_upload_dir, you'll see: if (defined('UPLOADS') && ! (is_multisite() && get_site_option('ms_files_rewriting'))) { $dir = ABSPATH.UPLOADS; $url = trailingslashit($siteurl).UPLOADS; } So UPLOADS can only be used to define a foder relative to ABSPATH, which I guess is /WordPress folder in your setup. ...


0

To show it above the title you can do this. Add the following to your functions.php and make a js file of the same name in your theme directory. function admin_js_custom() { $adminjs = get_stylesheet_directory_uri() . '/admin-js.js'; echo '"<script type="text/javascript" src="'. $adminjs . '"></script>"'; } add_action('admin_footer', ...


0

You can do this by hooking into the edit-post.php page. There are a variety of hooks you could use, for example, if you want to display a message below the edit title field, you could hook into edit_form_after_title. See the example code I have below with comments: add_action( 'edit_form_after_title', // the hook 'wpse_228208' // the function ); ...


0

You're using the reserved public query variable name as your custom one. It can e.g. affect the canonical redirect by setting page_id and name for a different page. Change it to something else to avoid possible name collision, like kenan_video_slug: add_rewrite_rule( '^watch/([^/]*)$', 'index.php?pagename=watch&kenan_video_slug=$matches[1]', ...


0

Static pages: Valid? Yes. You absolutely can add static pages that have nothing to do with a blog aside from using WordPress "routing" API out of the box and the database. Styles, Script: How? Simply add your custom styles and scripts to your theme. Then register and enqueue them. You can add your own Page Templates. Since WP 3.4 the actual page template ...


0

You don't need to pass the from name and email to PHPMailer in your code as it will take it from $headers so try the following: add_action( "phpmailer_init", "send_smtp_email" ); function send_smtp_email( $phpmailer ) { // ini_set("sendmail_from","xyz@gmail.com"); // ini_set("sendmail_path","xyz@gmail.com"); // Define that we are sending with SMTP ...


1

You can save your time and server load by not using wp_register_script and wp_register_style when you don't need them definitely. wp_enqueue_style and wp_enqueue_script do the same job themselves when not involving excessive functions. Here is easier and more readable code up to date with the accepted answer by @vancoder: <?php function opby_theme() { ...


3

is_singular doesn't handle archives. Try is_post_type_archive( 'limitedrun' );


1

You could do this with custom shortcodes or in some plugins with saved layouts. Many pagebuilder give the option to save predefined layouts. Try out this plugin if you want to create the predefined layouts programmatically. https://github.com/WebDevStudios/WDS-Simple-Page-Builder


0

If you're already experienced with HTML & CSS, then I'd suggest starting by building pages the way you'd like them and then looking at https://codex.wordpress.org/Template_Tags to see how you can replace key sections of the pages dynamically from WordPress.


0

I assume you're already properly using the WP Metadata API https://codex.wordpress.org/Metadata_API to attach the field to new comments and you just want to backfill for existing comments by stuffing the database? If it was my problem, I wouldn't bother and would assume in my code that absence of meta implied no likes. If you use update_meta_data() to ...


0

First, calculate the number of whole days from your start date, then take the modulus of this and the total number of posts in 'products'. This will give a 'post number' which you can use in the loop to show only the relevant post. So, if you have three posts $days_elapsed % $post_count would look like: | days | mod | -------------- | 0 | 0 | | 1 | ...


0

I have added pagination in order history page and it is working. Replace below code above loop $customer_orders1 = get_posts(apply_filters('woocommerce_my_account_my_orders_query', array( 'numberposts' => -1, 'meta_key' => '_customer_user', 'meta_value' => get_current_user_id(), 'post_type' => wc_get_order_types('view-orders'), ...


0

You can get users by user meta, using the WP_User_Query class. There's a great explanation at https://tommcfarlin.com/get-user-by-meta-data/


0

Why not build a blog style website first? If you're new to WordPress, it's better to start with something relatively easy, where there are lots of tutorials for. Practicing will give you the skills to reach for something higher, like the list of ambitions you give. If you need all those things you say right now, you're better of with buying a decent ...


1

It's not classified as plugins. It's also not a WordPress glossary and often called: Tabs which are built on Settings API and some tricks with $_GET request. There're many Q&As, references you can learn from. This topic seems to be the most relevant one for you. Yes, you can do it with template_include filter. These Q&As may be helpful too.


1

To append text to the end of the titles in that widget and nothing more i.e. does not matter the URL, you can just use some CSS. <li> <a class="my-folder-categories">Category 1</a> </li> a.my-folder-categories-folder:after {content:" folder"; This will effectivly make the text appear as so: category 1 folder Be sure to add ...


0

I've found the exact solution to my question here: http://wordpress.stackexchange.com/a/17687/92505 Here's the exact code I used after some modification to make it work on my situation. Add the following code to functions.php where 'sidebar-1' is your sidebar ID. 'recent-posts' is the name of the widget your want yo hide. 12 is the length of the string ...


3

It doesn't work because WordPress isn't loaded within the context of editor-style.php, and you're actually getting a fatal error (get_theme_mod undefined). Enable error logging and you'll see what I mean. Rather than pointing directly to a custom PHP file, you should use an "endpoint" within WordPress: add_editor_style( admin_url( ...


0

Here is version for any post type, in case if you are using custom post type function has_children($post_ID = null) { if ($post_ID === null) { global $post; $post_ID = $post->ID; } $query = new WP_Query(array('post_parent' => $post_ID, 'post_type' => 'any')); return $query->have_posts(); }


1

Here is an sample of my plugin's code where I set a custom post type "aei_team_member" and add 2 columns (Prénom and Photo where Photo is a thumbnail) in admin list using : manage_${post_type}_posts_columns and manage_{$post_type}_posts_custom_column Further information can be found here: ...


0

sounds like a .htaccess issue use a standard theme - still got the error? yes --> investigate your .htaccess file in the root of your site is the rewrite module loaded --> check with phpinfo() on your local server no --> investigate a .htaccess file within the template directory in both cases: check the rewrite rules within the .htaccess file


0

I'm interpreting that the static page you intend to show is a static page for the home page of your site. If that's the case, and the static page is truly static, I recommend saving the page as index.html and saving it (via ftp) right next to your WP index.php file in the root folder of your domain. The .html file will be served up before the .php file, ...


0

Its wordpress feature to add <p> tags automatic, so that a non programmer who don't have knowledge of html tags also can publish posts/pages on wordpress. Wordpress arranges tags for them. However this feature also becomes trouble (In some cases) for programmers to set up pages. So there are 2 ways to handle this issue. First: ...


0

You will have to walk/map/filter the array before printing them. There're plenty of array_*() functions provided by PHP for that. Example: $custom = get_post_custom(); // Remove all strings starting with `_` array_filter( $custom, function( $data, $name ) { return "_" !== substr( $name, 0, 1 ); }, ARRAY_FILTER_USE_BOTH ); foreach ( $custom as $field ) ...


0

You can upload an image to your theme and add this to your functions: add_action("login_head", "my_login_head"); function my_login_head() { echo " <style> body.login #login h1 a { background: url('".get_bloginfo('template_url')."/path to your image/logo-login.gif') no-repeat scroll center top transparent; height: 90px; ...


0

Here is an example authentication plugin. It will pull information from your php session variables. This is how to use it: save it into a file mycustom-auth.php modify the constants near the top of the class put it into wp-content/plugins/mycustom_auth or wp-content/mu-plugins enable it in wp-admin log out of WP and log in again. You should see one ...


1

WordPress's authentication system is made up of pluggable functions, which means that you can write a plugin that has a function named, say, wp_authenticate(), and your site will use your wp_authenticate() function instead of the native WordPress one. Your comment about is_user_logged_in() (on your original post) is obviated by the fact that ...


1

Within the wp_get_document_title() function we have: // If it's a search, use a dynamic search results title. } elseif ( is_search() ) { /* translators: %s: search phrase */ $title['title'] = sprintf( __( 'Search Results for &#8220;%s&#8221;' ), get_search_query() ); so you could hook into the ...


1

Is using Auth0 (http://www.auth0.com) maybe an option for you? They have a very good Wordpress plugin. I think you could integrate your system and do a Single Sign On (SSO) using the plugin. I think it's a better option for you to do some stuff on your system to integrate (since you know the system and can probably be more productive), using this ...


0

I've discovered that is_home() and is_front_page() don't deliver what's expected for multisites. My workaround using built in PHP goodies: if($_SERVER['REQUEST_URI'] == '/') { // you must be on the home page }


0

No need for a routine here - use the WordPress hook system to "attach" a function that will run when a post is published: // https://codex.wordpress.org/Plugin_API/Action_Reference/publish_post function wpse_225371_post_published( $post_id, $post ) { // Do your thang } add_action( 'post_published', 'wpse_225371_post_published', 10, 2 );



Top 50 recent answers are included