Quantcast
Channel: WordPress › Support » Forum: Hacks - Recent Topics
Viewing all 8245 articles
Browse latest View live

morollian on "Page with the same name as an actual directory"

$
0
0

Hello!
I'm having troubles with a website based on Wordpress 4.0.

In my website there is a page wich must have certain name, let's call it mandatory_name. I can do nothing about it because this name (and consequently the url) are mandatory by law. The problem is that already exisits a directory with the same name.

THE PROBLEM: When a user types the url http://www.mywebsite/mandatory_name, the browser shows the content of the folder /mandatory_name instead of the content of the page "mandatory_name".

Any clue would be very appreciated... I'm so lost here!


Iudex on "A plugin to replace shortcode with data"

$
0
0

I'm making a WordPress site for a small hotel. They want their prices on individual pages. When they change prices, it will be an extensive job (different rooms, languages etc.).

Is there a plugin or so, where I can make a table in backend (like a spreadsheet), lets say:

Room - Adults - Children
1 - 200 - 50
2 - 150 - 50

And then use this data using shortcode, like for example [room-1-adult], which then shows '200'.

mncplus on "Code Error"

$
0
0

webroot / wp-admin / js / accordion.min.js

!function(a){function b(a){var b=a.closest(".accordion-section"),c=b.find("[aria-expanded]").first(),d=b.closest(".accordion-container"),e=d.find(".open"),f=e.find("[aria-expanded]").first(),g=b.find(".accordion-section-content");b.hasClass("cannot-expand")||(d.addClass("opening"),b.hasClass("open")?(b.toggleClass("open"),g.toggle(!0).slideToggle(150)):(f.attr("aria-expanded","false"),e.removeClass("open"),e.find(".accordion-section-content").show().slideUp(150),g.toggle(!1).slideToggle(150),b.toggleClass("open")),setTimeout(function(){d.removeClass("opening")},150),c&&c.attr("aria-expanded",String("false"===c.attr("aria-expanded"))))}a(document).ready(function(){a(".accordion-container").on("click keydown",".accordion-section-title",function(c){("keydown"!==c.type||13===c.which)&&(c.preventDefault(),b(a(this)))})})}(jQuery);

the above file is giving the error code. Please advice.

driftmagazine on "I do not want to the_modified_time changed when admin change"

$
0
0

I do not want to the_modified_time changed when admin change something.

If I as an admin wants to make small changes in post I do not want to the_modified_time be changed, is it possible?

imarkelis on "Can't display dashboard widget content"

$
0
0

I'm trying to display dashboard widget content and i get the message

Warning: call_user_func() expects parameter 1 to be a valid callback, function 'couponsgen_create_dashboard_widget' not found or invalid function name in C:\wamp\www\wpdev1\wp-admin\includes\template.php on line 1037

My code for creating the widget is

<?php

class Couponsgen_Admin {

	/**
	 * The ID of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $plugin_name    The ID of this plugin.
	 */
	private $plugin_name;

	/**
	 * The version of this plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 * @var      string    $version    The current version of this plugin.
	 */
	private $version;

	/**
	 * Initialize the class and set its properties.
	 *
	 * @since    1.0.0
	 * @param      string    $plugin_name       The name of this plugin.
	 * @param      string    $version    The version of this plugin.
	 */
	public function __construct( $plugin_name, $version ) {

		$this->plugin_name = $plugin_name;
		$this->version = $version;

	}

	/**
	 * Register the stylesheets for the admin area.
	 *
	 * @since    1.0.0
	 */
	public function enqueue_styles() {

		/**
		 * This function is provided for demonstration purposes only.
		 *
		 * An instance of this class should be passed to the run() function
		 * defined in Couponsgen_Loader as all of the hooks are defined
		 * in that particular class.
		 *
		 * The Couponsgen_Loader will then create the relationship
		 * between the defined hooks and the functions defined in this
		 * class.
		 */

		wp_enqueue_style( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'css/couponsgen-admin.css', array(), $this->version, 'all' );

	}

	/**
	 * Register the JavaScript for the admin area.
	 *
	 * @since    1.0.0
	 */
	public function enqueue_scripts() {

		/**
		 * This function is provided for demonstration purposes only.
		 *
		 * An instance of this class should be passed to the run() function
		 * defined in Couponsgen_Loader as all of the hooks are defined
		 * in that particular class.
		 *
		 * The Couponsgen_Loader will then create the relationship
		 * between the defined hooks and the functions defined in this
		 * class.
		 */

		wp_enqueue_script( $this->plugin_name, plugin_dir_url( __FILE__ ) . 'js/couponsgen-admin.js', array( 'jquery' ), $this->version, false );

	}

        // call function to create our dashboard widget
        public function couponsgen_add_dashboard_widget() {
            wp_add_dashboard_widget(
                'couponsgen_dashboard_widget',
                'Coupons Generator Dashboard Widget',
                'couponsgen_create_dashboard_widget'
            );
        }

        // function to display our dashboard widget content
        public function couponsgen_create_dashboard_widget() {
           echo "<p>Hello World! This is my couponsgen Dashboard Widget</p>";
        }

        public function add_plugin_admin_menu() {
            add_options_page( 'Coupons Generator plugin Setup', 'Coupons Gen', 'manage_options', $this->plugin_name, array($this, 'display_plugin_setup_page'));
        }

        public function add_action_links( $links ) {
            $settings_link = array(
                '<a href="' . admin_url( 'options-general.php?page=' . $this->plugin_name ) . '">' . __('Settings', $this->plugin_name) . '</a>',
            );
            return array_merge(  $settings_link, $links );

        }

        public function display_plugin_setup_page() {
            include_once( 'partials/couponsgen-admin-display.php' );
        }

}

and for adding the action

<?php

class Couponsgen {

	/**
	 * The loader that's responsible for maintaining and registering all hooks that power
	 * the plugin.
	 *
	 * @since    1.0.0
	 * @access   protected
	 * @var      Couponsgen_Loader    $loader    Maintains and registers all hooks for the plugin.
	 */
	protected $loader;

	/**
	 * The unique identifier of this plugin.
	 *
	 * @since    1.0.0
	 * @access   protected
	 * @var      string    $plugin_name    The string used to uniquely identify this plugin.
	 */
	protected $plugin_name;

        /**
	 * The current version of the plugin.
	 *
	 * @since    1.0.0
	 * @access   protected
	 * @var      string    $version    The current version of the plugin.
	 */
	protected $version;

	/**
	 * Define the core functionality of the plugin.
	 *
	 * Set the plugin name and the plugin version that can be used throughout the plugin.
	 * Load the dependencies, define the locale, and set the hooks for the admin area and
	 * the public-facing side of the site.
	 *
	 * @since    1.0.0
	 */
	public function __construct() {

		$this->plugin_name = 'couponsgen';
		$this->version = '1.0.0';

		$this->load_dependencies();
		$this->set_locale();
		$this->define_admin_hooks();
		$this->define_public_hooks();

	}

	/**
	 * Load the required dependencies for this plugin.
	 *
	 * Include the following files that make up the plugin:
	 *
	 * - Couponsgen_Loader. Orchestrates the hooks of the plugin.
	 * - Couponsgen_i18n. Defines internationalization functionality.
	 * - Couponsgen_Admin. Defines all hooks for the admin area.
	 * - Couponsgen_Public. Defines all hooks for the public side of the site.
	 *
	 * Create an instance of the loader which will be used to register the hooks
	 * with WordPress.
	 *
	 * @since    1.0.0
	 * @access   private
	 */
	private function load_dependencies() {

		/**
		 * The class responsible for orchestrating the actions and filters of the
		 * core plugin.
		 */
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-couponsgen-loader.php';

		/**
		 * The class responsible for defining internationalization functionality
		 * of the plugin.
		 */
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-couponsgen-i18n.php';

		/**
		 * The class responsible for defining all actions that occur in the admin area.
		 */
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'admin/class-couponsgen-admin.php';

		/**
		 * The class responsible for defining all actions that occur in the public-facing
		 * side of the site.
		 */
		require_once plugin_dir_path( dirname( __FILE__ ) ) . 'public/class-couponsgen-public.php';

		$this->loader = new Couponsgen_Loader();

	}

	/**
	 * Define the locale for this plugin for internationalization.
	 *
	 * Uses the Couponsgen_i18n class in order to set the domain and to register the hook
	 * with WordPress.
	 *
	 * @since    1.0.0
	 * @access   private
	 */
	private function set_locale() {

		$plugin_i18n = new Couponsgen_i18n();

		$this->loader->add_action( 'plugins_loaded', $plugin_i18n, 'load_plugin_textdomain' );

	}

	/**
	 * Register all of the hooks related to the admin area functionality
	 * of the plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 */
	private function define_admin_hooks() {

		$plugin_admin = new Couponsgen_Admin( $this->get_plugin_name(), $this->get_version() );

		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_styles' );
		$this->loader->add_action( 'admin_enqueue_scripts', $plugin_admin, 'enqueue_scripts' );

                $this->loader->add_action( 'admin_menu', $plugin_admin, 'add_plugin_admin_menu' );
                $this->loader->add_action('wp_dashboard_setup', $plugin_admin, 'couponsgen_add_dashboard_widget');
                // Add Settings link to the plugin
                $plugin_basename = plugin_basename( plugin_dir_path( __DIR__ ) . $this->plugin_name . '.php' );
                $this->loader->add_filter( 'plugin_action_links_' . $plugin_basename, $plugin_admin, 'add_action_links' );
	}

	/**
	 * Register all of the hooks related to the public-facing functionality
	 * of the plugin.
	 *
	 * @since    1.0.0
	 * @access   private
	 */
	private function define_public_hooks() {

                require_once plugin_dir_path( dirname( __FILE__ ) ) . 'includes/class-couponsgen-loader.php';

		$plugin_public = new Couponsgen_Public( $this->get_plugin_name(), $this->get_version() );

		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_styles' );
		$this->loader->add_action( 'wp_enqueue_scripts', $plugin_public, 'enqueue_scripts' );
	}

	/**
	 * Run the loader to execute all of the hooks with WordPress.
	 *
	 * @since    1.0.0
	 */
	public function run() {
		$this->loader->run();
	}

	/**
	 * The name of the plugin used to uniquely identify it within the context of
	 * WordPress and to define internationalization functionality.
	 *
	 * @since     1.0.0
	 * @return    string    The name of the plugin.
	 */
	public function get_plugin_name() {
		return $this->plugin_name;
	}

	/**
	 * The reference to the class that orchestrates the hooks with the plugin.
	 *
	 * @since     1.0.0
	 * @return    Couponsgen_Loader    Orchestrates the hooks of the plugin.
	 */
	public function get_loader() {
		return $this->loader;
	}

	/**
	 * Retrieve the version number of the plugin.
	 *
	 * @since     1.0.0
	 * @return    string    The version number of the plugin.
	 */
	public function get_version() {
		return $this->version;
	}
}

Can someone please help?

ionurboz on "Why do not working attachment parent Post Type display name"

$
0
0

1- Attachment parent post id : wp_get_post_parent_id()

2- Attachment parent post type with id : get_post_type(line 1)

3- Attachment parent post type object by slug: get_post_type_object(line 2)

4- Attachment parent post type Labels in Name: line 3->labels->singular_name`

FULL VERSION:

$parent_post_type_name = get_post_type_object(get_post_type(wp_get_post_parent_id()))->labels->singular_name

it return null !

Help me please;

www.'sitename'.com/custom_post_type_post/attachment_image

I am need in the this loop, parent /custom_post_type_post/ post_type name :) ty.

hvogue009 on "share icons not displayed on wordpress dashboard"

$
0
0

After installing jetpack plugin i have connected to wordpress.com also when i check the share setting. no social media icons were displayed,only Enabled Services - Google + is displayed. which is not displayed in live preview. and in Available Services- Email,Print,Pocket were displayed and not dragable.

please help me sir.

DjPrison on "Wordpress Homepage "Latest posts" site ID"

$
0
0

Hi

I have wordpress 4.4 and i have Wordpress Homepage that is showing all latest posts. How would i get that Site´s ID?

Thanks for help


Pcosta88 on "Data Not Saving in Plugin"

$
0
0

Theme: 2012

Trying to make my own plugin using a tutorial in a book I have and the data is not saving. Not sure why or where to begin. Any pointers would be helpful.

Note: I've kept getting an illegal offset warning but I have since turned debugging off.

Code is over 100 lines and is located at a Pastebin:
http://pastebin.com/Q34iMYPk

anglerramesh on "Wordpress two header with media device"

$
0
0

I am using word press responsive template, i have two header files, i need call php with media query's

@media screen and (max-width: 1024px) {<?php get_header(); ?> }

@media screen and (max-width: 768px) {<?php get_header(sub); ?> }

Ynasr on "Showing events "neighborhood" details - google map api"

$
0
0

Hi,

I am trying to show the "neighborhood" information for user generated events. Basically, i would like to know how i could use the events coordinate generated by events-manager/google map api to find out the name of the neighborhood for that events.

For example, instead of just having "28 jones street, New York, NY, 10014, USA" i would like to have "28 jones street, West Village, New York, NY, 10014, USA.

Is it something events-manager supports out of the box. If not, how could i achieve that. FYI - i am not a developer but i can mess around with basic syntax.

Many thanks,
Yvan

vision4liberia on "Arabic language around my Login Page Panel"

kkmarch7 on "Adding Custom Fields to search results excerpt"

$
0
0

Hi I am using Ajax Search Pro and currently the search results excerpt pulls from content and is one long sentence. I wanted to have the search results excerpt return a list like this:

Phone Number:
Serving Area:
Email:

The above information (phone number, serving area, and email) currently exist in content, taxonomies and custom fields. I added to taxonomies and custom fields in the process of testing ways to parse the data.

Ajax Search Pro uses a result template, code included below.

?>
<div class='item asp_result_<?php echo $r->content_type; ?>'>

    <?php do_action('asp_res_vertical_begin_item'); ?>

    <div class='content'>

        <?php if (!empty($r->image)): ?>

            <?php do_action('asp_res_vertical_before_image'); ?>

            <div class='image'>
                <img src='<?php echo $r->image; ?>'>
                <div class='void'></div>
            </div>

            <?php do_action('asp_res_vertical_after_image'); ?>

        <?php endif; ?>

       <h3><a href='<?php echo $r->link; ?>'<?php echo ($s_options['results_click_blank'])?" target='_blank'":""; ?>>
                <?php echo $r->title; ?>
                <?php if ($s_options['resultareaclickable'] == 1): ?>
                <span class='overlap'></span>
                <?php endif; ?>
        </a></h3>

        <?php if ( !empty($r->date) || !empty($r->author) ): ?>

        <div class='etc'>

            <?php if ( $s_options['showauthor'] == 1 && !empty($r->author) ): ?>
            <span class='author'><?php echo $r->author; ?></span>
            <?php endif; ?>

            <?php if ( $s_options['showdate'] == 1 && !empty($r->date) ): ?>
            <span class='date'><?php echo $r->date; ?></span>
            <?php endif; ?>

        </div>

        <?php endif; ?>

        <?php if ($s_options['showdescription'] == 1): ?>
        <!--<p class='desc'>-->
            <?php echo $r->content; ?>
        <!--</p>-->
        <?php endif; ?>

    </div>

    <?php do_action('asp_res_vertical_after_content'); ?>

    <div class='clear'></div>

    <?php do_action('asp_res_vertical_end_item'); ?>

</div>
<div class="asp_spacer"></div>

The plug-in developer provided the following information:

Printing post meta into the content

Since you have access to the post ID via the $r->id, you can get custom field values and put them before/after the content easily.

If you look ate lines 76-80 in vertical.php, you see the content is being printed there:

<?php if ($s_options['showdescription'] == 1): ?>

    <?php echo $r->content; ?>

<?php endif; ?>

Let's get and print a meta value there in a custom div element and modify the code like this:

<?php
// This is the meta key
$key = 'my_meta_key';

// We only want to do this on posts/pages/custom post types
if ($r->content_type == 'pagepost') {
  $meta_value = get_post_meta( $r->id, $key, true );
  if ($meta_value != '')
    echo "<div class='my_class'>" . $meta_value . "</div>";
}
?>

<?php if ($s_options['showdescription'] == 1): ?>

    <?php echo $r->content; ?>

<?php endif; ?>

If the post meta with the 'my_meta_key' exists, then it will be printed before the description, inside a new div element.

I edited and added the above code to this:

<?php
// This is the meta key
$key = 'phonenumber';

// We only want to do this on posts/pages/custom post types
if ($r->content_type == 'pagepost') {
  $meta_value = get_post_meta( $r->id, $key, true );
  if ($meta_value != '')
    echo "<div class='my_class'>" . $meta_value . "</div>";
}
?>

This code only returns "array" in the search results excerpt. Can someone please point me in the right direction? I do not know if it is best to parse the taxonomies or the custom fields or if there is a way to display the content in the excerpt as a list. Any advice is greatly appreciated!

Alino on "Adding custom fields to the profile page - extracting from database"

$
0
0

I'm trying to add custom fields to the WP user profile page. These fields need to be pre-filled with data I have already obtained from when the user signed up that is located in the usermeta table, but the user can edit this data if they choose. I'm just wondering how I achieve this, I have researched but found only basic tutorials on adding things such as more social media options to the profile page.

Thank you for your help.

ajia.im on "Adding Shortcode to PHP File in WordPress"

$
0
0

I currently have the below code:
wp_mail( get_option( 'admin_email' ), "{$user->user_login}", "{$user->user_login} has logged in from a different computer." );

and I'm trying to add the Shortcode:
[whatsmyip ip='yes' country='yes']

My guess is that I need to add the below code somewhere where it needs to be added in the above code as I keep getting errors.
echo do_shortcode( '[whatsmyip ip='yes' country='yes']' );

Any ideas?


rishadjb on "username_exists() fails - Call to a member function get() on null in cache.php"

$
0
0

Hi. I am new to these forums, and fairly new to using WordPress as well.

I am making an app which will let my users register through the app, and hence add their info into my database.

I am trying to use this function username_exists() in the PHP code below.

require('../wp-includes/class-phpass.php');
require('../wp-includes/plugin.php');
require('../wp-includes/user.php');
require('../wp-includes/pluggable.php');
require('../wp-includes/capabilities.php');
require('../wp-includes/class-wp-user.php');
require('../wp-includes/formatting.php');
require('../wp-includes/cache.php');
require('../wp-includes/wp-db.php');
require('../wp-includes/class-wp-error.php');

//get the username from the app via GET
$username = $_GET['username'];

if ( username_exists( $username ) )
           echo "Username In Use!";
       else
           echo "Username Not In Use!";

But running this with a username that exists in my database gives this error:

Fatal error: Call to a member function get() on null in /home2/extrovee/public_html/wp-includes/cache.php on line 123

The source of the error at line 123 is

function wp_cache_get( $key, $group = '', $force = false, &$found = null ) {
121	        global $wp_object_cache;
122
123	        return $wp_object_cache->get( $key, $group, $force, $found );
124	}

I am not sure why this error is happening, and how to resolve it.

Any help is appreciated.

Also, is there any plugin that allows things like adding/deleting users from android app, so I don't need to re-invent the wheel? Regardless, it would good understand the cause and solution for this error.

Thanks,
R

chickspirit on "WooCommerce Product Image to External Link in New Window"

$
0
0

I have an external link product and would like the featured image on the single product page to link to the external page in a new window.

Out of the box the image, when clicked, opens in a lightbox.

The section of code I have to adjust is in the product-image.php

<div class="images">

	<?php
		if ( has_post_thumbnail() ) {

			$image_title 	= esc_attr( get_the_title( get_post_thumbnail_id() ) );
			$image_caption 	= get_post( get_post_thumbnail_id() )->post_excerpt;
			$image_link  	= wp_get_attachment_url( get_post_thumbnail_id() );
			$image       	= get_the_post_thumbnail( $post->ID, apply_filters( 'single_product_large_thumbnail_size', 'shop_single' ), array(
				'title'	=> $image_title,
				'alt'	=> $image_title
				) );

Specifically I need to change this line:
$image_link = wp_get_attachment_url( get_post_thumbnail_id() );

I changed it to this:
$image_link = esc_url( $product->get_product_url() );
which accomplished the image opening the external link when clicked. However it's opening in the same window and I'd like it to open in a new window.

I tried this:
$image_link = esc_url( $product->get_product_url(), array('target' => '_blank', 'rel' => 'new_window') );
But now it just kind of refreshes the page and takes me nowhere.

Suggestions? Thank you!
Page I'm trying this on.

fistcloud on "Change for of property to random"

$
0
0

Hi
I want to change the code of prporty archive to random

this is the code of archive

<?php

global $wp_query;

$default_sort = aviators_settings_get_value('properties', 'properties', 'default_sort');
if(isset($_GET['filter_sort_by'])) {
    $default_sort = $_GET['filter_sort_by'];
}

echo View::render('archive-property.twig', array(
    'wp_query' => aviators_properties_filter(TRUE),
    'properties' => aviators_properties_filter(FALSE),
    'default_sort' => $default_sort,
));

thnks

[ No bumping please. ]

julienkos on "Function !is_front_page not working"

$
0
0

Hi!

I am trying to add a span to blog post titles, based upon their category on the website and I don't want it to show up in the home page in the widgets section at the bottom. Here is my code:

---

add_filter( 'the_title', 'my_modify_title', 10, 2 );
function my_modify_title( $title, $id ) {
if( in_category( 'Fitness', $id ) ) {
$title = '<span class="fitness"></span> ' . $title;
} else if( in_category( 'Recipe', $id ) ) {
$title = '<span class="recipe"></span> ' . $title;
} else if( in_category( 'Life etc', $id ) ) {
$title = '<span class="life"></span> ' . $title;
} else if( in_category( 'Soul', $id ) ) {
$title = '<span class="soul"></span> ' . $title;
}
return $title;
}

---

I tried adding:

!is_front_page() to the if and it isn't working.

add_filter( 'the_title', 'my_modify_title', 10, 2 );
function my_modify_title( $title, $id ) {
if( !is_front_page() && in_category( 'Fitness', $id ) ) {
$title = '<span class="fitness"></span> ' . $title;
} else if( !is_front_page() && in_category( 'Recipe', $id ) ) {
$title = '<span class="recipe"></span> ' . $title;
} else if( !is_front_page() && in_category( 'Life etc', $id ) ) {
$title = '<span class="life"></span> ' . $title;
} else if( !is_front_page() && in_category( 'Soul', $id ) ) {
$title = '<span class="soul"></span> ' . $title;
}
return $title;
}

---

Please let me know if I'm doing something wrong here...

The website is currently at: http://utopiandesigns.ca/barlinfitness/

critch on "add categories in alt-tags and title-tags (post_thumbnails)"

$
0
0

hello guys,

I want to add the categories in this code for alt-tags and title-tags (post_thumbnails).
This is a code snippet from my functions.php.
How can I add the categories for the posts?
I tried "post_category" but it doesnt work.

function isa_add_img_title( $attr, $attachment = null ) {
    $attr['title'] = trim( strip_tags( $attachment->post_title ));
    $attr['alt'] = trim( strip_tags( $attachment->_wp_attachment_image_alt ));
    return $attr;}

Best,
Mitch

Viewing all 8245 articles
Browse latest View live




Latest Images