wordpress-plugin

WordPress global $post variable is empty

不羁的心 提交于 2019-12-20 04:12:25
问题 I'm working on a wordpress plugin(managing background image), when I try to use global $post; print_r($post); the object is empty. Probably there is some required data (I dont know what.) Please help me if you know. 回答1: The WordPress global variable $post contains the data of the current Post within the The Loop. This means that WordPress will assign a value to this variable in each loop iteration. Consecuently, if you're trying to access $post from anywhere in your code outside the WP loop,

Failed to import “Contact form 1”: Invalid post type wpcf7_contact_form Failed to import Media “db_site.sql_.txt”

ε祈祈猫儿з 提交于 2019-12-20 03:05:31
问题 I'm new to web development specially with wordpress. I created a website using wordpress as cms framework. I imported a database to my wordpress dashboard, all went well but the problem was some of the content was never imported successfully and the message is this, "...Failed to import Media “db_site.sql_.txt” and Failed to import “Contact form 1”: Invalid post type wpcf7_contact_form.." what could be the problem with this? I appreciate any help from you. Thanks!..=) 回答1: You are missing the

Image missing and required - Wordpress AMP Structure doesn't add Image attribute

白昼怎懂夜的黑 提交于 2019-12-20 01:44:08
问题 When validating my wordpress posts using Google's Structured Data Testing Tool, I get the following error: "Image: missing and required" I have the official wordpress AMP plugin installed that generated the AMP pages for me. The problem is that it doesn't popular the "image" attribute for BlogPosting . In the plugin there is a code that I think should generate it, but it's not running anywhere: private function get_post_image_metadata() { $post_image_meta = null; $post_image_id = false; if (

Create a new page with wp_insert_post ()

ぐ巨炮叔叔 提交于 2019-12-19 11:25:03
问题 I have the following code in a PHP function that is activated when I install my plugin that lets you create a post or page. Works perfect and make the page if the $post_type is "post", but if the $post_type is "page", then it does not work, does not create the page.: $my_post = array( 'post_title' => 'My page Reql', 'post_type' => 'page', 'post_name' => 'my-page', 'post_content' => 'This is my page reql.', 'post_status' => 'publish', 'comment_status' => 'closed', 'ping_status' => 'closed',

Make images private in Wordpress

我是研究僧i 提交于 2019-12-18 18:49:07
问题 I'm making a site, that I would like to make private. The most important part, is that the images on the domain can't be seen, without the user logging in first. So I would like all traffic to be redirected to www.DOMAINNAME.com/wp-admin (also for images), if the user isn't logged in. Here's what I've tried: 1) Plugins. I've tried both Wordpress Force Login , the plugin wp-require-login and a Coming soon page and Maintenance mode. 2) Adding a function from this answer. Which is this: function

Wordpress - Show parent category AND subcategory name in subcategory archive URL

和自甴很熟 提交于 2019-12-18 15:17:43
问题 I'm having some trouble with Wordpress category/subcategory archive URLs. For example, I want to be able to display this archive: http://faroutmagazine.co.uk/wp/track-of-the-day while keeping its parent category in the URL, making it http://faroutmagazine.co.uk/wp/music/track-of-the-day Previously, I was just getting a "This is embarrassing..." 404 message when accessing the /music/track-of-the-day URL (even though that's the one that was appearing in the View option under categories in the

How rename a plugin title > Wordpress > Dashboard

Deadly 提交于 2019-12-18 13:37:34
问题 Please, may someone help me? I need change the name of a plugin installed in my wordpress (Only the name in the admin bar is fine ;) . Thanks! Preview: 回答1: Here's the process to change the labels (I changed WooCommerce to "Stall" in my example). You could try that with the gettext filter in the following manner. Use this in your functions.php file function rename_header_to_logo( $translated, $original, $domain ) { $strings = array( 'WooCommerce' => 'Stall', 'Custom Header' => 'Custom Stall'

Can I remove transients in the wp_options table of my WordPress install?

陌路散爱 提交于 2019-12-18 09:59:03
问题 I have recently noticed that my wp_options table seems to be a bit large. It contains 1161 rows, and is about 2.1mb in size. I have installed Clean Options. It looks like development stopped on the plugin back in 2010, but it still did the job. I now have a long list of potentially orphaned entries. Is there an easy way to go about sorting these, and figuring out which to remove and which to keep? Also, could this be responsible for causing performance issues with the website? Thank you for

Multiple settings Wordpress Options Page plugin

淺唱寂寞╮ 提交于 2019-12-18 05:09:10
问题 I want to make an Options page with multiple settings for my plugin. I want to use this code as a start: http://codex.wordpress.org/Creating_Options_Pages#Example_.232 <?php class wctest{ public function __construct(){ if(is_admin()){ add_action('admin_menu', array($this, 'add_plugin_page')); add_action('admin_init', array($this, 'page_init')); } } public function add_plugin_page(){ // This page will be under "Settings" add_options_page('Settings Admin', 'Settings', 'manage_options', 'test

how to load Javascript in Wordpress Plugin

♀尐吖头ヾ 提交于 2019-12-17 16:06:12
问题 Can someone show me how to include this javascript file into my wordpress plugin. I have tried all the wp_enqeue_script() methods but nothing happens. ok here is my example plugin code with comments explaining what I would like. <?php /* Plugin Name: Ava Test Plugin URI: http://#.com Description: A plugin that is used for my javascript tests Author: Ronny Kibet Author URI: http://ronnykibet.com version: 1.001 */ include(popup.js); /*when I include it this way, it works fine, but gives an